VOOZH about

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

⇱ Pandas Series dt.weekofyear Method | Get Week of Year in Pandas Series - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Pandas Series dt.weekofyear Method | Get Week of Year in Pandas Series

Last Updated : 11 Jul, 2025

The dt.weekofyear attribute returns a Series containing the week ordinal of the year in the underlying data of the given series object.

Example

Output:

👁 weekofyear attribute output

Syntax

Syntax: Series.dt.weekofyear 

Parameter:  None 

Returns: Series containing the week ordinal

How to Extract Week of the Year From Date in Pandas Series

To extract the week of the year from the date in the Pandas Series we use the dt.weekofyear attribute of the Pandas library in Python.

Let us understand it better with an example:

Example:

Use the Series.dt.weekofyear 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.weekofyear attribute to return the week ordinal of the year in the underlying data of the given Series object.

Output :

👁 week ordinal returned

As we can see in the output, the Series.dt.weekofyear attribute has successfully accessed and returned the week ordinal of the year in the underlying data of the given series object.

Comment

Explore