This seems like a straightforward question, but I've been stuck for a while on it now. Apologies if this has been asked already. I have the following pandas dataframe:
import pandas as pd
zed = pd.DataFrame({'gameDate': {0: datetime.date(2019, 12, 12),
1: datetime.date(2019, 12, 12),
2: datetime.date(2019, 12, 12),
3: datetime.date(2019, 12, 12),
4: datetime.date(2019, 12, 12)},
'periodType': {0: 'REGULAR',
1: 'REGULAR',
2: 'REGULAR',
3: 'REGULAR',
4: 'REGULAR'}})
and when I check to see the dtypes of this dataframe, I get the following output:
print(zed.dtypes)
gameDate object
periodType object
dtype: object
How can the date types be distinguished from the string types when both are returned as object? I have a much larger dataframe for which I need to identify all columns of type date (not datetime or timestamp, but specifically date only, like above), but I don't specifically know the column names. I'd like to use something like the .dtypes function to help reveal these columns.
I could create a function that tests if the string is of the format yyyy-mm-dd, but that seems tedious.
Thanks!