
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Pandas - Display the end time of the period for each element in the given PeriodIndex object
To display the end time of the period for each element in the given PeriodIndex object, use the PeriodIndex.end_time property.
At first, import the required libraries −
import pandas as pd
Create a PeriodIndex object. PeriodIndex is an immutable ndarray holding ordinal values indicating regular periods in time. We have set the frequency using the "freq" parameter −
periodIndex = pd.PeriodIndex(['2018-07-25', '2019-10-30', '2020-11-20', '2021-09-15', '2022-03-12', '2023-06-18'], freq="D")
Display PeriodIndex object −
print("PeriodIndex...\n", periodIndex)
Display the end time −
print("\nEnd Time...\n", periodIndex.end_time)
Example
Following is the code −
import pandas as pd # Create a PeriodIndex object # PeriodIndex is an immutable ndarray holding ordinal values indicating regular periods in time # We have set the frequency using the "freq" parameter periodIndex = pd.PeriodIndex(['2018-07-25', '2019-10-30', '2020-11-20', '2021-09-15', '2022-03-12', '2023-06-18'], freq="D") # Display PeriodIndex object print("PeriodIndex...\n", periodIndex) # Display PeriodIndex frequency print("\nPeriodIndex frequency...\n", periodIndex.freq) # Display the end time print("\nEnd Time...\n", periodIndex.end_time)
Output
This will produce the following code −
PeriodIndex... PeriodIndex(['2018-07-25', '2019-10-30', '2020-11-20', '2021-09-15', '2022-03-12', '2023-06-18'], dtype='period[D]') PeriodIndex frequency... <Day> End Time... DatetimeIndex(['2018-07-25 23:59:59.999999999', '2019-10-30 23:59:59.999999999', '2020-11-20 23:59:59.999999999', '2021-09-15 23:59:59.999999999', '2022-03-12 23:59:59.999999999', '2023-06-18 23:59:59.999999999'], dtype='datetime64[ns]', freq=None)
- Related Articles
- Python Pandas - Find the end time for the given Period object
- Python Pandas - Find the start time for the given Period object
- Python Pandas - Get the hour of the period from the PeriodIndex object
- Python Pandas - Get the minute of the period from the PeriodIndex object
- Python Pandas - Get the seconds of the period from the PeriodIndex object
- Python Pandas - Get the week of the period from the PeriodIndex object
- Python Pandas - Get the month number of the period from the PeriodIndex object
- Python Pandas - Display the quarter of the date from the PeriodIndex object
- Python Pandas - Get the frequency for the given Period object
- Python Pandas - Format the Period object and display the Time with 24-Hour format
- Python Pandas - Format the Period object and display Quarter
- Python Pandas - Create a PeriodIndex and get the days of the period
- Python Pandas - Return the string alias of the Time series frequency applied on the given Period object
- Python Pandas - Return the frequency object from the PeriodIndex object
- Python Pandas - Display the end time of the custom business hour in 24h format from the BusinessHour offset object

Advertisements