pandas.Timestamp.as_unit

pandas 3.1.1 · Arrays, scalars, and data types · method

Change the storage unit of time values, subject to precision and rounding rules.

Call syntax

Timestamp.as_unit(unit, round_ok=True)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
unit Required
Positional or keyword
{"ns", "us", "ms", "s"}

Specify the time unit represented by each number or required by the result.

round_ok Optional
Positional or keyword
Default True
bool

Returns

Timestamp