pandas.DataFrame.to_timestamp

pandas 3.1.1 · DataFrame · method

Convert the PeriodIndex on the selected axis to timestamps representing period starts or ends.

Call syntax

DataFrame.to_timestamp(freq=None, how='start', axis=0, copy=…)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
freq Optional
Positional or keyword
Default None
str

Specify the frequency or offset, such as "D" for a day or "MS" for a calendar month start.

how Optional
Positional or keyword
Default 'start'
{'start', 'end', 's', 'e'}

Choose a policy such as a join type or a missing-value removal rule.

axis Optional
Positional or keyword
Default 0
{0 or 'index', 1 or 'columns'}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

copy Optional
Positional or keyword
bool

Control whether data is copied where the API supports that choice.

Returns

DataFrame with DatetimeIndex