Concatenate pandas DataFrames


This entry is part 2 of 2 in the series Pandas EDA Joining

What does it mean to concatenate DataFrames? A DataFrame is like a table with rows and columns. To concatenate two DataFrames is to stack one on top of the other so that the columns line up exactly, OR to join two DataFrames left to right (side by side). We use the pandas concat() function to do these.

In SQL, stacking on top of is accomplished by UNION and concatenating side bt side is accomplished with a JOIN. In pandas, we use merge to join and concat to union.

Use Case

You may have data arriving periodically. You want to combine the data together and analyze it. Perhaps you have daily sales data arriving each day. Perhaps you have data arriving once a month. Perhaps the data is sales data with the date in obe column, the item sold in another and the quantity and price in another column. In any case, you may wish to concatenate the data.

Series Navigation<< EDA Joining with Pandas

Leave a Reply