Guest User

Untitled

a guest
Jan 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. def create_hour_q_id(df, indexdf):
  2. df['hour_q'] = df['timestamp'].dt.time
  3. # indexdf = extract_hour(indexdf)
  4. hour_q_to_id = indexdf.groupby('desc_heure', as_index=False).agg({'id_heure': 'first'})
  5. hour_q_to_id.rename(columns={'desc_heure': 'hour_q', 'id_heure': 'id_hour_q'}, inplace=True)
  6. merged = df.merge(hour_q_to_id, on=['hour_q'], how='left')
  7. return merged
Add Comment
Please, Sign In to add comment