Forum

Notifications
Clear all

Extracting Temperature Data  

   RSS

0

Hi, why does the method august = df[df.loc['2010-08', 'Temperature']] not work? 

The suggested answer was "august = df['Temperature']['2010-08']". But 2010-08 is not a column in itself? the dates were saved as row entries. 

1 Answer
0

Hi! If you're referring to the exercise Probability of High Temperatures, the suggested way is df_climate.loc['2010-Aug','Temperature']

This is the standard way of extracting/filtering data from a DataFrame.

You may be confusing this with something like df_climate[df_climate['Temperature']>20]. This works because df_climate['Temperature']>20 returns a boolean Series, which the DataFrame df_climate can use to filter its rows. df[df.loc['2010-08', 'Temperature']] doesn't work because df.loc['2010-08', 'Temperature'] returns a Series with dtype float64, which is not bool.

Share:

Delete your account