Python Pandas - Find the start time for the given Period object

To find the start time for a given Period object, use the start_time property. A Pandas Period represents a specific time span, and start_time returns the exact timestamp when that period begins.

What is start_time Property?

The start_time property returns a Timestamp object representing the start of the period. This is useful when you need the precise beginning moment of a time period ?

import pandas as pd

# Create a Period object
period = pd.Period("2020-09-22")
print("Period:", period)
print("Start time:", period.start_time)
print("Type:", type(period.start_time))
Period: 2020-09-22
Start time: 2020-09-22 00:00:00
Type: <class 'pandas._libs.tslibs.timestamps.Timestamp'>

Example with Different Frequencies

Different frequency periods have different start times. Let's compare daily, monthly, and yearly periods ?

import pandas as pd

# Create periods with different frequencies
daily = pd.Period("2020-09-22", freq="D")
monthly = pd.Period("2020-09", freq="M")
yearly = pd.Period("2020", freq="Y")

print("Daily period start time:", daily.start_time)
print("Monthly period start time:", monthly.start_time)
print("Yearly period start time:", yearly.start_time)
Daily period start time: 2020-09-22 00:00:00
Monthly period start time: 2020-09-01 00:00:00
Yearly period start time: 2020-01-01 00:00:00

Creating Periods with Specific Parameters

You can create periods using specific date/time components and get their start times ?

import pandas as pd

# Create Period objects with specific parameters
period1 = pd.Period("2020-09-22")
period2 = pd.Period(freq="D", year=2021, month=2, day=14, hour=2, minute=35)

# Display the Period objects
print("Period1:", period1)
print("Period2:", period2)

# Get the start time from both Period objects
print("\nStart time from Period1:", period1.start_time)
print("Start time from Period2:", period2.start_time)
Period1: 2020-09-22
Period2: 2021-02-14

Start time from Period1: 2020-09-22 00:00:00
Start time from Period2: 2021-02-14 00:00:00

Comparison with end_time

Understanding the difference between start_time and end_time helps clarify period boundaries ?

import pandas as pd

# Create a monthly period
monthly_period = pd.Period("2020-09", freq="M")

print("Monthly Period:", monthly_period)
print("Start time:", monthly_period.start_time)
print("End time:", monthly_period.end_time)
Monthly Period: 2020-09
Start time: 2020-09-01 00:00:00
End time: 2020-09-30 23:59:59.999999999

Conclusion

The start_time property returns a Timestamp representing the exact beginning of a Period object. This is essential for time series analysis where you need precise period boundaries for calculations or filtering operations.

Updated on: 2026-03-26T17:43:59+05:30

379 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements