Skip to content

pandas/concat-columns-unchecked

Rule concat-columns-unchecked
Pack pandas
Severity info
Fix none, edit by hand
Library versions every version

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.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

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.

Browse the other rules of the pandas pack.