Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

pandas
communitycreator

How to obtain the minute of the hour component of a given period

Onyejiaku Theophilus Chidalu

Overview

The minute attribute of a Period (an equivalent of Timestamp) is used to obtain the minute of the hour component of the given period.

Syntax

Period.minute
Syntax for the minute attribute in Pandas

Parameters

This, being an attribute, takes no parameter value.

Return value

The hour attribute returns an integer representing the minute of the hour with value between 0 and 59.

Example

# A code to illustrate the minute attribute
# importing the pandas library
import pandas as pd

# creating a Period object
a = pd.Period('2022-5-2 13:03:12.050000')

# obtaining the minute of the hour
b = a.minute

# printing the value
print("Today is minute", b, "of the hour")
Implementing the minute attribute of a Period

Explanation

  • Line 3: We import the pandas library.
  • Line 6: We create a Period object, a.
  • Line 9: We obtain the minute of the hour from the Period object using the minute attribute. We assign the result to a variable, b.
  • Line 12: We print the value of b.

RELATED TAGS

pandas
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu
RELATED COURSES

View all Courses

Keep Exploring