I have a huge DataFrame where the columns aren\'t ever in order nor do I know their name.
What do I do to find all the columns which are datetime types?
Most of
Since each column of a pandas DataFrame is a pandas Series simply iterate through list of column names and conditionally check for series.dtype
of datetime (typically datetime64[ns]):
for col in df.columns:
if df[col].dtype == 'datetime64[ns]':
print(col)
Or as list comprehension:
[col for col in df.columns if df[col].dtype == 'datetime64[ns]']
Or as a series filter:
df.dtypes[df.dtypes=='datetime64[ns]']