pandas.Timestamp.to_period

Timestamp.to_period()

Return an period of which this timestamp is an observation.

Examples

>>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651')
>>> ts.to_period(freq='Y) # Year end frequency
numpy.datetime64('2020-03-14T15:32:52.192548651')
>>> ts.to_period(freq='M') # Month end frequency
Period('2020-03', 'M')
>>> ts.to_period(freq='W') # Weekly frequency
Period('2020-03-09/2020-03-15', 'W-SUN')
>>> ts.to_period(freq='Q') # Quarter end frequency
Period('2020Q1', 'Q-DEC')

© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/api/pandas.Timestamp.to_period.html