I have been analyzing the Seoul Bike Sharing Demand dataset, which is available at Seoul Bike Sharing Demand . During my analysis, I found the need to use a resampling method. To accomplish this, I loaded the dataset into a Pandas DataFrame, which I named df. Then, I applied the desired resampling method using the following code snippet:
label_encoders = {}
categorical_columns = list()
for column in df.columns:
if df.dtypes[column] in [np.int64, np.float64]:
pass
else:
if column != 'Date':
categorical_columns.append(column)
Label_encoder = LabelEncoder()
label_encoders[column] = Label_encoder
numerical_column = Label_encoder.fit_transform(df[column])
df[column] = numerical_column
ndf = df.copy()
ndf.set_index('Date', inplace = True)
I want to draw a correlation between Holidays and Rented Bike count.
Holiday = ndf[ndf['Holiday'] == 0].resample('D')['Rented Bike Count'].sum()
But I expected that it does not include days that are not holiday which in this case , their Holiday column should not be 1(0 -> Holiday, 1 -> Not Holiday) . But when I run this code, the result is something like this:
Date
2017-12-22 7184
2017-12-23 0
2017-12-24 2014
2017-12-25 3966
2017-12-26 0
...
2018-10-05 0
2018-10-06 0
2018-10-07 0
2018-10-08 0
2018-10-09 0
Freq: D, Name: Rented Bike Count, Length: 292, dtype: int64
For example 2017-12-23 is not Holiday but is included in the result and other days like
2018-10-05. But if I run the code with a minor change for non-holiday days it seems to work fine
Holiday = ndf[ndf['Holiday'] == 1].resample('D')['Rented Bike Count'].sum()
And it as expected does not included the holiday days in the processing . I mean why this problem pops up? What am I doing wrong in this case? Thanks in advance