In a codebase I am looking at, I see the following
local_timezone = get_local_timezone()
df1["start_time"] = df1.start_time.dt.tz_convert(local_timezone) # pandas dataframe
df_merged = pd.merge(df1, df2, left_on=["start_time"])
df_merged["start_time"] = df_merged["start_time"].dt.tz_localize(None)
I've been under the impression that only either one of tz_localize
and tz_convert
is needed, and not both, to convert a timezone to the local timezone. What is the purpose of using both here?