Skip to content

pandas/concat-columns-unchecked

Pack Severity Fix Versions
pandas info none, edit by hand All versions

concat(axis=1) pairs rows by index label and keeps every label of every frame, so one differing label adds a row of missing values and turns int columns into floats. Pass join="inner" to keep only shared labels, or join="outer" to say the missing values are meant.

both = pd.concat([left, right], axis=1)
both = pd.concat([left, right], axis=1, join="inner")

The rule reports pd.concat([...], axis=1) without join=, which pairs rows by index label and keeps every label of every frame. The table shows two frames of 4 rows whose labels differ in one row.

Call Rows Dtype of both columns
pd.concat([left, right], axis=1) 5, with a missing value float64
pd.concat([left, right], axis=1, join="inner") 3 shared rows int64

xpd has no automatic fix, so make the change by hand.

Write join="outer" when you want the missing values.

concat(axis=1) pairs rows by index label and keeps every label of every frame. With one label that differed, two frames of 4 rows gave 5 rows, and both int64 columns became float64 with a missing value. Pass join="inner" to keep only the labels that every frame has, or join="outer" to say that the missing values are meant.

See all rules in the pandas pack.