I am trying to filter the columns in a pandas dataframe based on whether they are of type date or not. I can figure out which ones are, but then would have to parse that ou
This code automatically identify the date column and change datatype from object to 'datetime64[ns]'. Once you got date datatype you can easily perform other operations.
for col in data.columns:
if data[col].dtype == 'object':
try:
data[col] = pd.to_datetime(data[col])
except ValueError:
pass