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

Appending new rows

Appending of rows is performed using the .append() method of the DataFrame. The process of appending returns a new DataFrame with the data from the original DataFrame added first and then rows from the second. Appending does not perform alignment and can result in duplicate index labels.

The following code demonstrates appending two DataFrame objects extracted from the sp500 data. The first DataFrame consists of rows (by position) 0, 1 and 2, and the second consists of rows (also by position) 10, 11 and 2. The row at position 2 (with label ABBV) is included in both to demonstrate the creation of duplicate index labels.

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