Here is my code to remove the seconds that some values in my df[‘time’] column that have seconds (ie. 10:05:35).
df = df[pd.to_datetime(df['time'], errors='coerce').notna()]
df = df[pd.to_datetime(df['date'], errors='coerce').notna()]
# Remove the seconds by setting the floor to minutes 'T'
df['time'] = df['time'].df.floor('T')
After running the above code I get this error, can anyone help?
AttributeError: ‘Series’ object has no attribute ‘df’
>Solution :
I unfortunately can’t comment yet, otherwise I would’ve commented.
Looking at this SO question it seems you have made a typo and need df['time'] = df['time'].dt.floor('T') where the difference is the dt instead of the df in between the dots.