11

Combining Pandas Objects

Introduction

A wide variety of options are available to combine two or more DataFrames or Series together. The append method is the least flexible and only allows for new rows to be appended to a DataFrame. The concat method is very versatile and can combine any number of DataFrames or Series on either axis. The join method provides fast lookups by aligning a column of one DataFrame to the index of others. The merge method provides SQL-like capabilities to join two DataFrames together.

Appending new rows to DataFrames

When performing data analysis, it is far more common to create new columns than new rows. This is because a new row of data usually represents a new observation, and as an analyst, it is typically not ...

Get Pandas 1.x Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.