v Encode Days Of The Week - Machine Learning

Encode Days Of The Week

Preliminaries

# Load library
import pandas as pd

Create Date And Time Data

# Create dates
dates = pd.Series(pd.date_range('2/2/2002', periods=3, freq='M'))

# View data
dates
0   2002-02-28
1   2002-03-31
2   2002-04-30
dtype: datetime64[ns]

Show Days Of The Week

# Show days of the week
dates.dt.weekday_name
0    Thursday
1      Sunday
2     Tuesday
dtype: object