O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Switching axes of alignment

The pd.concat() function allows you to specify the axis on which to apply the alignment during the concatenation. The following concatenates the two DataFrame objects along the column axis, switching alignment to be along the rows index:

This result now contains duplicate columns. This is because the concatenation first aligns by the row index labels of each DataFrame object, and then fills in the columns from the first DataFrame object and then the second without regard to the row index labels.

The following demonstrates a concatenation along the column axis with two DataFrame objects that have several row index ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required