I am trying to identify whether a column in my dataframe has a date or not. For context, my real dataset has hundreds of columns, and I can't go through and manually identify if a column is a date or not. Ultimately, I need to get the dates in a similar format so that I can compare different versions of my datasets and see what has changed.
df = pd.DataFrame({
'date1':['07/23/01', '06/25/17', np.nan, '1/5/06'],
'date2':[np.nan, '12/01/08', '9/02/03', np.nan],
'str1':['aaaaf', '23fgsafg', 'dsf5t', np.nan]})
mask = df.astype(str).apply(lambda x : x.str.match('\d{1,2}/\d{1,2}/\d{2}').all())
I've tried the following code, but each of these variables come up as "false". What am I missing here?
Thanks