pandas.concat

pandas 3.1.1 · General functions · function

Stack pandas objects along rows or place them side by side. Use axis=1 for columns and ignore_index=True to renumber the combined axis.

Call syntax

pd.concat(…) Full signature
pd.concat(
    objs,
    *,
    axis=0,
    join='outer',
    ignore_index=False,
    keys=None,
    levels=None,
    names=None,
    verify_integrity=False,
    sort=…,
    copy=…,
    union_categories=False,
)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
objs Required
Positional or keyword
an iterable or mapping of Series or DataFrame objects

Pass a sequence or a mapping of Series and DataFrames to combine.

axis Optional
Keyword only
Default 0
{0/'index', 1/'columns'}

Use 0 to stack rows and 1 to put columns next to each other.

join Optional
Keyword only
Default 'outer'
{'inner', 'outer'}

Choose "outer" to retain all labels on the other axis or "inner" to retain only shared labels.

ignore_index Optional
Keyword only
Default False
bool

Give the resulting axis new integer labels where supported.

keys Optional
Keyword only
Default None
sequence

Provide grouping, dictionary, index, or concatenation keys for this operation.

levels Optional
Keyword only
Default None
list of sequences

Supply level definitions for a hierarchical index.

names Optional
Keyword only
Default None
list

Supply explicit names for labels, fields, or levels.

verify_integrity Optional
Keyword only
Default False
bool

Check that the result satisfies the API's integrity requirements, such as unique labels.

sort Optional
Keyword only
bool

Choose whether the resulting labels or groups are sorted where supported.

copy Optional
Keyword only
bool

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

union_categories Optional
Keyword only
Default False
bool

Returns

object, type of objs