VOOZH about

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

⇱ Pandas Series dt.hour | Extract Hour Part from Time Stamp - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Pandas Series dt.hour | Extract Hour Part from Time Stamp

Last Updated : 11 Jul, 2025

Pandas dt.hour attribute returns a NumPy array containing the hour of the DateTime in the underlying data of the given Series object.

Example

Output

👁 dt.hour attribute output

Syntax

Syntax: Series.dt.hour 

Parameter: None 

Returns: NumPy array containing hour values

How to Extract Hour from DateTime Object in Pandas Series

To extract the hour value from the DateTime object in the Pandas Series we use the dt.hour attribute of the Pandas library in Python.

Let us understand it better with an example:

Example:

Use the Series.dt.hour attribute to return the hour of the DateTime in the underlying data of the given Series object.

Output :

👁 datetime series created

Now we will use the Series.dt.hour attribute to return the hour of the datetime in the underlying data of the given Series object.

Output :

👁 extracted hour value from datetime

As we can see in the output, the Series.dt.hour attribute has successfully accessed and returned the hour of the DateTime in the underlying data of the given series object.

Comment

Explore