Thilina Madumal
Thilina Madumal

Reputation: 101

Python Pandas Resample Gives False instead of NaN or NA

I'm using pandas dataframe with datetime index to work with timeseries data. Since I'm working with observed data there can be quite no. of missing values.

However I wanted to resample the observed timeseries as follows,

freq = 'H'
obs_mean = obs_mean.resample(freq).sum()

Here for missing values, it is okay to give NaN/NA because those can be handled via .dropna or fillna().

The problem here is, instead of NaN/NA it gives 'False' as the value.

before resampling:
                    value
time                      
2018-05-18 08:15:00  0.200
2018-05-18 08:20:00  0.600
2018-05-18 08:25:00  0.600
2018-05-18 08:30:00  0.400
2018-05-18 08:35:00  0.400
2018-05-18 10:10:00  2.000
2018-05-18 10:15:00  5.400

after resampling:
                      value
time                       
2018-05-18 08:00:00   2.200
2018-05-18 09:00:00   False
2018-05-18 10:00:00  24.800
2018-05-18 11:00:00   0.800
2018-05-18 12:00:00  21.400
2018-05-18 13:00:00   2.400

Upvotes: 0

Views: 214

Answers (1)

admiralgrafspee
admiralgrafspee

Reputation: 11

I came across the same problem and I found there's missing original data during those periods... you haven't got data during 09:00-09:59.

Upvotes: 1

Related Questions