I'm importing data into pandas and want to remove any timezones – if they're present in the data. If the data has a time zone, the following code works successfully:
col = "my_date_column"
df[col] = pd.to_datetime(df[col]).dt.tz_localize(None) # We don't want timezones...
If the data does not contain a timezone, I'd like to use the following code:
df[col] = pd.to_datetime(df[col])
My issue is that I'm not sure how to test for timezone in the datetime object / series.