Title: Encode Days Of The Week
Slug: encode_days_of_the_week
Summary: How to the days of the week for dates and times for machine learning in Python.
Date: 2017-09-11 12:00
Category: Machine Learning
Tags: Preprocessing Dates And Times
Authors: Chris Albon
In [1]:
# Load library
import pandas as pd
In [2]:
# Create dates
dates = pd.Series(pd.date_range('2/2/2002', periods=3, freq='M'))
# View data
dates
Out[2]:
In [3]:
# Show days of the week
dates.dt.weekday_name
Out[3]: