i have dataframe mixed date formats in column. of in format dd/mm/yyyy , of in format d/m/y. how can set column datetime applying appropriate format depending on value of cell? reading csv file:
dayofweek,date friday,22/05/2015 friday,10/2/12 friday,10/10/14 friday,21/10/2011 friday,8/7/11
df = pd.read_csv('dates.txt', parse_dates=['date'], dayfirst=true) df.info() <class 'pandas.core.frame.dataframe'> rangeindex: 5 entries, 0 4 data columns (total 2 columns): dayofweek 5 non-null object date 5 non-null datetime64[ns] dtypes: datetime64[ns](1), object(1) memory usage: 100.0+ bytes print(df) dayofweek date 0 friday 2015-05-22 1 friday 2012-02-10 2 friday 2014-10-10 3 friday 2011-10-21 4 friday 2011-07-08
Comments
Post a Comment