We need a method that will take in a datetime object from a dataframe column and create columns for:
Day of the month
Day of the year
Month
Year
Lunar cycle
National US holiday
Doing so will allow us to analyze our information for patterns such as violent crimes and werewolves attacking citizens.
Here is our starting code:
df['Joined'] = pd.to_datetime(df['Joined'])
df['Joined year'] = df['Joined'].dt.year # adding in a feature that's just the year
df['Joined month'] = df['Joined'].dt.month # adding in a feature that's just the year
df['Day'] = df['Joined'].dt.day # adding in a feature that's just the year
print(min(df['Joined']), max(df['Joined']))
df['Joined'].head()
We need a method that will take in a datetime object from a dataframe column and create columns for:
Doing so will allow us to analyze our information for patterns such as violent crimes and werewolves attacking citizens.
Here is our starting code:
df['Joined'] = pd.to_datetime(df['Joined']) df['Joined year'] = df['Joined'].dt.year # adding in a feature that's just the year df['Joined month'] = df['Joined'].dt.month # adding in a feature that's just the year df['Day'] = df['Joined'].dt.day # adding in a feature that's just the year print(min(df['Joined']), max(df['Joined'])) df['Joined'].head()