Learning_datascience
Learning_datascience

Reputation: 99

"None of [Float64Index([56.0, ..\n dtype='float64', length=1057499)] are in the [columns]" Pandas dataframe

Please excuse any obvious mistakes as I am new to Pandas and coding in general.

I am filtering the original dataframe and creating a copy with chosen columns. This is how my data frame looks like:

(dataframe filter routine):

df_new=df.filter(['date','location','value','lat_final','lon_final'], axis=1)
df_new = df_new.set_index('date')
print (df_new.head())

The new dataframe:

    location  value lat_final lon_final
date                                                              
2015-06-30 09:40:00+05:30   XYZI   56.0   28.6508   77.3152
2015-06-30 11:00:00+05:30   MNOP   36.0   28.6683   77.1167
2015-06-30 17:10:00+05:30   QRST   71.0   28.6508   77.3152
2015-06-30 11:00:00+05:30   UVWX   98.0   28.6508   77.3152
2015-06-30 09:40:00+05:30   XXYZ   26.0   28.6683   77.1167

While trying to perform some operations on columns in this new dataframe, I am getting the none type error. These are the operations I am performing:

(This step goes fine)

f=df_new[df_new['value']>=0]
f.drop(f[f['value'] >1500].index, inplace = True)
f.drop(f[f['value'] <2].index, inplace = True)

(The error crops up here):

#Filteration steps:
#Step1: grouping into 12h or n hour intervals:
diurnal = f[f['value']].resample('12h')

Where am I going wrong? Any help will be much appreciated.

Upvotes: 0

Views: 1187

Answers (1)

Oriol Mirosa
Oriol Mirosa

Reputation: 2826

This: f[f['value']] will give you an error. If you want to resample the value column, you should select it properly, and also tell resample how you want to aggregate the values (sum, mean?). Something like this:

f['value'].resample('12h').sum()

Upvotes: 1

Related Questions