I have the following dataframe:
ID 2019-01-31 00:00:00
0 R01 1
How can I remove the time from the column name, so that I can slice the df by df['31/01/2019']?
You can do something like that:
from datetime import datetime
df.columns = [i.strftime('%Y-%m-%d') if isinstance(i, datetime) else i for i in df.columns]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With