converting a pandas date to week number

Just access the week attribute of Series.dt.isocalendar():

Example:

In [286]:
df['Date'].dt.isocalendar().week

Out[286]:
0    25
dtype: int64

In [287]:
df['Week_Number'] = df['Date'].dt.isocalendar().week
df

Out[287]:
        Date  Week_Number
0 2015-06-17           25

Leave a Comment