![]() |
VOOZH | about |
Pandas dt.hour attribute returns a NumPy array containing the hour of the DateTime in the underlying data of the given Series object.
Output
Syntax: Series.dt.hour
Parameter: None
Returns: NumPy array containing hour values
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:
Use the Series.dt.hour attribute to return the hour of the DateTime in the underlying data of the given Series object.
Output :
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.