Below solution is slightly different to @jezrael in that seasons and weekdays are explicitly defined.
import pandas as pd
df = pd.DataFrame([['2017-01-01 00:00', '01/01/2017', 'Jan', 'Mon', '00:00', 60.23],
['2017-01-01 01:00', '01/01/2017', 'Jan', 'Sat', '01:00', 60.73],
['2017-01-01 02:00', '01/01/2017', 'May', 'Tue', '02:00', 75.99],
['2017-01-01 03:00', '01/01/2017', 'Jan', 'Sun', '03:00', 60.76],
['2017-01-01 04:00', '01/01/2017', 'Sep', 'Sat', '04:00', 49.01]],
columns=['timestamp', 'date', 'month', 'day', 'hour', 'price'])
def InvertKeyListDictionary(input_dict):
return {w: k for k, v in input_dict.items() for w in v}
season_map = {'Spring': ['Mar', 'Apr', 'May'],
'Summer': ['Jun', 'Jul', 'Aug'],
'Autumn': ['Sep', 'Oct', 'Nov'],
'Winter': ['Dec', 'Jan', 'Feb']}
weekend_map = {'Weekday': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
'Weekend': ['Sat', 'Sun']}
month_map = InvertKeyListDictionary(season_map)
day_map = InvertKeyListDictionary(weekend_map)
df['season'] = df['month'].map(month_map)
df['daytype'] = df['day'].map(day_map)
df_groups = df.groupby(['season', 'daytype'])
df_groups.get_group(('Winter', 'Weekend'))
# output
# timestamp date month day hour price season daytype
# 2017-01-01 01:00 01/01/2017 Jan Sat 01:00 60.73 Winter Weekend
# 2017-01-01 03:00 01/01/2017 Jan Sun 03:00 60.76 Winter Weekend