For the following df
I would like to extract columns with “dates”:
df = pd.DataFrame([["USD", 12.3, 1, 23.33, 33.1],["USD", 32.1, 2, 34.44, 23.1]],columns= ['currency', '1999-07-31', 'amount', '1999-10-31', '2000-01-31'])
Current code:
datetime_types = ["datetime", "datetime64", "datetime64[ns]", "datetimetz"]
dates = df.columns.to_frame().select_dtypes(include=datetime_types)
Current output:
dates.to_string()
'Empty DataFramenColumns: []nIndex: [currency, 1999-07-31, amount, 1999-10-31, 2000-01-31]'
Desired output:
[1999-07-31, 1999-10-31, 2000-01-31]