How can I match data only by months and dates and not by year:
Advertisement
Answer
Convert Time
column to datetimes and then to custom format MM/DD/
and then aggregate:
JavaScript
x
4
1
df['Time'] = pd.to_datetime(df['Time']).dt.strftime('%m/%d/')
2
3
df1 = df.groupby('Time').first()
4
If need aggregate sum
, mean
if duplicates use:
JavaScript
1
3
1
df2 = df.groupby('Time').sum(min_count=1)
2
df3 = df.groupby('Time').mean()
3