I have multiple data frames with a datetime column as a string. Datetime formats vary across columns in the dataframe or across dataframes. I want to get a unix timestamp that reflects the local timezone.
For example, one such dataframe is the following:
import pandas as pd
time_dict = {"datetime": ["2023-08-15T15:32:47.687+00:00", ""]}
test_df = pd.DataFrame(time_dict)
I tried a number of simple functions. They didn’t produce the unix timestamp in the correct time zone. When I tried to make some corrections for the timezone, I encountered a TypeError saying that the timezone was already present in the date.
I will provide a solution below, but maybe someone has a better one.