Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

pandas
pandas timestamp
timestamp.minute
datetime
communitycreator

How to obtain the minute in a date in pandas

Onyejiaku Theophilus Chidalu

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 library
import pandas as pd

# creating a date time object
my_date = pd.Timestamp('2022-04-29T7:48:52.192548651')

# obtaining the minute value from the given date
print("The minute value from the Timestamp object is: ", my_date.minute)
Implementing the minute attribute of a date time object

Explanation

  • Line 3: We import the pandas module.
  • Line 6: We create a Timestamp ( datetime) object and name it my_date.
  • Line 9: We obtain the minute value from the given Timestamp object, my_date, by using the minute attribute, and we print it.

RELATED TAGS

pandas
pandas timestamp
timestamp.minute
datetime
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu
RELATED COURSES

View all Courses

Keep Exploring