VOOZH about

URL: https://www.geeksforgeeks.org/pandas/pandas-series-dt-week/

⇱ Pandas Series dt.week | Extract Week Number from DateTime Series - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Pandas Series dt.week | Extract Week Number from DateTime Series

Last Updated : 11 Jul, 2025

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

Output

👁 dt.week attribute output

Syntax

Syntax: Series.dt.week 

Parameter : None 

Returns: NumPy array containing week values

How to Extract Week From DateTime Series

To 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.

Output :

👁 datetime series created

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.

Output :

👁 week ordinals of given timestamps

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

Explore