Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create_hour_q_id(df, indexdf):
- df['hour_q'] = df['timestamp'].dt.time
- # indexdf = extract_hour(indexdf)
- hour_q_to_id = indexdf.groupby('desc_heure', as_index=False).agg({'id_heure': 'first'})
- hour_q_to_id.rename(columns={'desc_heure': 'hour_q', 'id_heure': 'id_hour_q'}, inplace=True)
- merged = df.merge(hour_q_to_id, on=['hour_q'], how='left')
- return merged
Add Comment
Please, Sign In to add comment