When I read CSV/Excel files, the datetime column has an 'object' type. It would be easy to identify it if it was the only one, however I got few more object type columns -strings- that does not contain time.
I'm looking for a way to identify the time column without knowing its name nor its position. All I could do for the moment is something like this:
dfs = df.loc[:, df.dtypes == object]
#Or
df = df.select_dtypes(include = ['object'])
Example of csv file:
timestep,winddirection,windspeed,windspd_10m_gust,Hs,waveheight_max,waveperiod,peakperiod_1d,secondarywavedirection,windwaveheight,secondarywaveperiod,primarywavedirection,swellheigth,primarywaveperiod,temperature
7/15/2021 16:00,161,21.6609024,23.5205124,2.58,3,4.6,6.2,162,1.43,5.2,101,1.21,8.1,24.5
7/15/2021 17:00,165,21.466518,23.326128,2.56,3,4.6,6.2,164,1.41,5.2,100,1.2,8.1,24.7
7/15/2021 18:00,167,20.8833648,22.5485904,2.53,2.9,4.6,6.2,165,1.39,5.2,101,1.19,8.1,24.6
7/15/2021 19:00,167,20.494596,21.9654372,2.5,2.9,4.6,6.2,167,1.34,5.1,103,1.21,8,24.7
7/15/2021 20:00,167,20.6889804,22.354206,2.48,2.8,4.6,6.2,166,1.33,5.1,100,1.19,8,24.8
7/15/2021 21:00,168,21.0777492,22.7429748,2.47,2.8,4.6,6.2,167,1.32,5.1,102,1.17,8.1,24.9
7/15/2021 22:00,168,21.2721336,23.1317436,2.46,2.8,4.6,6.2,167,1.34,5.1,99,1.14,8.2,25
7/15/2021 23:00,166,21.466518,23.326128,2.46,2.8,4.5,6.2,165,1.36,5.1,98,1.12,8.3,24.7
7/16/2021 0:00,169,21.0777492,22.7429748,2.46,2.8,4.5,6.1,167,1.35,5.1,97,1.13,8.3,24.2
7/16/2021 1:00,176,22.0496712,24.1036656,2.48,2.8,4.5,6.1,174,1.36,5,98,1.14,8.3,23.9
7/16/2021 2:00,177,22.43844,24.4924344,2.54,2.9,4.5,6.1,174,1.45,5.1,96,1.12,8.4,24.3
7/16/2021 3:00,181,23.410362,25.6587408,2.62,3.1,4.5,6.2,176,1.56,5.2,96,1.12,8.5,24.3
7/16/2021 4:00,181,24.1878996,26.6306628,2.68,3.2,4.6,6.2,178,1.65,5.3,96,1.1,8.5,24.2