application_vnd.jupyter.stderr_output_1.png
import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

dfs = {}
for name in ['train', 'test']:
    df = pd.read_csv('/kaggle/input/bike-sharing-demand/%s.csv' % name)
    df['_data'] = name
    dfs[name] = df

df = dfs['train'].append(dfs['test'])
df.columns = map(str.lower, df.columns)

dt = pd.DatetimeIndex(df['datetime'])
df.set_index(dt, inplace=True)
df['date'] = dt.date
df['day'] = dt.day
df['month'] = dt.month
df['year'] = dt.year
df['hour'] = dt.hour
df['dow'] = dt.dayofweek
df['woy'] = dt.weekofyear

df['peak'] = df[['hour', 'workingday']].apply(lambda x: (0, 1)[x['workingday'] == 1 and (x['hour'] == 8 or 17 <= x['hour'] <= 18 or 12 <= x['hour'] <= 13) or (x['workingday'] == 0 and 10 <= x['hour'] <= 19)], axis=1)