March 2020
Beginner to intermediate
352 pages
8h 40m
English
Next, we want to refactor the timezone based on our timezone:
import datetime import pytzdef refactor_timezone(x): est = pytz.timezone('US/Eastern') return x.astimezone(est)
Note that in the preceding code, I converted the timezone into the US/Eastern timezone. You can choose whatever timezone you like.
dfs['date'] = dfs['date'].apply(lambda x: refactor_timezone(x))
dfs['dayofweek'] = dfs['date'].apply(lambda x: x.weekday_name)dfs['dayofweek'] = pd.Categorical(dfs['dayofweek'], ...
Read now
Unlock full access