Pandas Series dt.week | Extract Week Number from DateTime Series Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Pandas dt.week attribute returns a NumPy array containing the week ordinal of the year in the underlying data of the given DateTime Series object. Example Python3 import pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] sr.index = idx sr = pd.to_datetime(sr) result = sr.dt.week print(result) Output SyntaxSyntax: Series.dt.week Parameter : None Returns: NumPy array containing week values How to Extract Week From DateTime SeriesTo extract the week value from the DateTime series we use the Series.dt.week attribute of the Pandas library in Python. Let us understand it better with an example: Example:Use the Series.dt.week attribute to return the week ordinal of the year in the underlying data of the given Series object. Python3 # importing pandas as pd import pandas as pd # Creating the Series sr = pd.Series(pd.date_range('2012-12-12 12:12', periods = 5, freq = 'M')) # Creating the index idx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] # set the index sr.index = idx # Print the series print(sr) Output : Now we will use the Series.dt.week attribute to return the week ordinal of the year in the underlying data of the given Series object. Python3 # return the week ordinal # of the year result = sr.dt.week # print the result print(result) Output : As we can see in the output, the Series.dt.week attribute has successfully accessed and returned the week ordinal of the year in the underlying data of the given series object. Comment More infoAdvertise with us Next Article Pandas Series dt.year | Extract Year Part from DateTime Series S Shubham__Ranjan Follow Improve Article Tags : Pandas Python-pandas Python pandas-series-datetime AI-ML-DS With Python Similar Reads Pandas Series dt.year | Extract Year Part from DateTime Series The dt.year attribute returns a Numpy array containing the year value of the DateTime Series ObjectExamplePythonimport pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] sr. 3 min read Pandas Series dt.year | Extract Year Part from DateTime Series The dt.year attribute returns a Numpy array containing the year value of the DateTime Series ObjectExamplePythonimport pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] sr. 3 min read Pandas Series dt.month | Extract Month Part From DateTime Series The dt.month attribute returns a NumPy array containing the month of the DateTime in the underlying data of the given Series object. Example Python3 import pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = ['Day 1', 'D 2 min read Pandas Series dt.month | Extract Month Part From DateTime Series The dt.month attribute returns a NumPy array containing the month of the DateTime in the underlying data of the given Series object. Example Python3 import pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = ['Day 1', 'D 2 min read Pandas Series dt.minute | Extract Minute from DateTime Series in Pandas Pandas Series.dt.minute attribute returns a NumPy array containing the minutes of the DateTime in the underlying data of the given series object. Example Python3 import pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = 2 min read Pandas Series dt.minute | Extract Minute from DateTime Series in Pandas Pandas Series.dt.minute attribute returns a NumPy array containing the minutes of the DateTime in the underlying data of the given series object. Example Python3 import pandas as pd sr = pd.Series(['2012-10-21 09:30', '2019-7-18 12:30', '2008-02-2 10:30', '2010-4-22 09:25', '2019-11-8 02:22']) idx = 2 min read Like