How to obtain the minute in a date in pandas
Overview
The minute attribute in Pandas is used to obtain the value of the minutes from the given Timestamp object. It is equivalent to Python's datetime object.
Syntax
Timestamp.minute
Syntax for the minute attribute
Parameter
As an attribute, minute takes no parameter value.
Return value
The minute attribute returns an int representing the minute value of the given date.
Code example
Let's look at the code below:
# A code to illustrate the minute attribute in Pandas# importing the pandas libraryimport pandas as pd# creating a date time objectmy_date = pd.Timestamp('2022-04-29T7:48:52.192548651')# obtaining the minute value from the given dateprint("The minute value from the Timestamp object is: ", my_date.minute)
Explanation
- Line 3: We import the pandas module.
- Line 6: We create a Timestamp (
datetime) object and name itmy_date. - Line 9: We obtain the minute value from the given Timestamp object,
my_date, by using theminuteattribute, and we print it.