Python | Pandas DatetimeIndex.minute

Python Methods and Functions

DatetimeIndex.minute Pandas DatetimeIndex.minute outputs an Index object containing the minute values ​​present in each of the DatetimeIndex object records.

Syntax: DatetimeIndex.minute

Return: Index containing minutes.

Example # 1: Use the DatetimeIndex.minute attribute to find the minute values ​​present in the DatetimeIndex object.

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex
# Here & # 39; T & # 39; represents frequency

didx = pd.DatetimeIndex (start = '2000-01-10 06:30' , freq = 'T'

periods = 3 , tz = 'Asia / Calcutta' )

 
# Print DatetimeIndex

print (didx)

Output:

Now we want to find all mine the exact values ​​present in the DatetimeIndex object.

# find all minute values ​​present in the object
didx.minute

Output:

As we can see from the output, the function returned an Index object containing the minute values ​​present in each object record DatetimeIndex. Here 30, 31 and 32 are the minute values ​​in the DatetimeIndex object records.

Example # 2: Use the DatetimeIndex.minute attribute to find the minute values ​​present in the DatetimeIndex object.

Output:

Now we want to find all minute values ​​present in the DatetimeIndex object.

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex
# Here BH represents the frequency of business hours

didx = pd.DatetimeIndex (start = ' 2014-08-01 10:05' , freq = 'BH ' ,

  periods = 5 , tz = 'Asia / Calcutta' )

  
# Print DatetimeIndex

print (didx)

# find all minute values ​​present in the object
didx.minute

Output:

As we can see from the output, the function returned an Index object containing the minute values ​​present in each entry DatetimeIndex object.





Get Solution for free from DataCamp guru