

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Pandas - Extract the minute from DateTimeIndex with specific time series frequency
To extract the minute from the DateTimeIndex with specific time series frequency, use the DateTimeIndex.minute property.
At first, import the required libraries −
import pandas as pd
Create a DatetimeIndex with period 6 and frequency as T i.e. minute. The timezone is Australia/Sydney −
datetimeindex = pd.date_range('2021-10-20 02:30:55', periods=6, tz='Australia/Sydney', freq='T')
Display DateTimeIndex −
print("DateTimeIndex...\n", datetimeindex)
Get the minute −
print("\nGetting the minute..\n",datetimeindex.minute)
Example
Following is the code −
import pandas as pd # DatetimeIndex with period 6 and frequency as T i.e. minute # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:55', periods=6, tz='Australia/Sydney', freq='T') # display DateTimeIndex print("DateTimeIndex...\n", datetimeindex) # display DateTimeIndex frequency print("DateTimeIndex frequency...\n", datetimeindex.freq) # get the minute print("\nGetting the minute..\n",datetimeindex.minute)
Output
This will produce the following code −
DateTimeIndex... DatetimeIndex(['2021-10-20 02:30:55+11:00', '2021-10-20 02:31:55+11:00', '2021-10-20 02:32:55+11:00', '2021-10-20 02:33:55+11:00', '2021-10-20 02:34:55+11:00', '2021-10-20 02:35:55+11:00'], dtype='datetime64[ns, Australia/Sydney]', freq='T') DateTimeIndex frequency... <Minute> Getting the minute.. Int64Index([30, 31, 32, 33, 34, 35], dtype='int64')
- Related Questions & Answers
- Python Pandas - Extract year from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the hour from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the seconds from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the microseconds from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the nanoseconds from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the timezone from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the day from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract month number from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the day of week from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the quarter of the date from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the ordinal day of year from the DateTimeIndex with specific time series frequency
- Python Pandas - Extract the frequency from the DateTimeIndex
- Python Pandas - How to Round the DateTimeIndex with minute frequency
- Python Pandas - Extract the frequency object as a string from the DateTimeIndex
- Python Pandas - How to Round the TimeDeltaIndex with minute frequency
Advertisements