pandas.DataFrame.truncate

pandas 3.1.1 · DataFrame · method

Keep labels within specified before and after bounds on a sorted axis.

Call syntax

DataFrame.truncate(before=None, after=None, axis=None, copy=…)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
before Optional
Positional or keyword
Default None
date, str, int

Set the earliest retained label for truncation.

after Optional
Positional or keyword
Default None
date, str, int

Set the latest retained label for truncation.

axis Optional
Positional or keyword
Default None
{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

type of caller