Convert the underlying int64 representaton to the given unit.
If False and the conversion requires rounding, raise.
Examples
>>> ts = pd.Timestamp('2023-01-01 00:00:00.01')
>>> ts
Timestamp('2023-01-01 00:00:00.010000')
>>> ts.unit
'ms'
>>> ts = ts.as_unit('s')
>>> ts
Timestamp('2023-01-01 00:00:00')
>>> ts.unit
's'
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.Timestamp.as_unit.html