Home > Blockchain >  How to exclude datetime formats in pandas when casting string Series to datetime and no format has b
How to exclude datetime formats in pandas when casting string Series to datetime and no format has b

Time:09-10

In the pandas.to_datetime function, pandas infers, for each cell, its format if no format has been specified. However, without specifying a particular format, how can we exclude certain formats from being used? (I am not refering to dayfirst or yearfirst parameters).

Something like:

df = pd.DataFrame({'dates': ['21-5-2018', '2/4/2000']})
df.dates = pd.to_datetime(df.dates, excluded_formats=['%m-           
  • Related