Reputation: 4623
I have a dataset like this
import pandas as pd
df = pd.DataFrame({'a' : ['30.09.2015', '13.10.2015 18:13:47' , '01.04.2012', '13.10.2015 18:25:36']})
I want to convert to time format
2015-09-30
2015-10-13
I tried to do different ways
pd.to_datetime(df['a'], format= '%d.%m.%Y %H:%M:%S')
pd.to_datetime(df['a'], format= '%d.%m.%Y')
pd.to_datetime(df['a'], format= c('%d.%m.%Y', '%d.%m.%Y %H:%M:%S'))
It's wrong. How to fix it?
Upvotes: 0
Views: 35
Reputation: 249384
You've made it harder than it needed to be! Just do this:
pd.to_datetime(df['a'])
Upvotes: 1