Skip to content
Advertisement

Create a Pandas Dataframe by appending one row at a time

How do I create an empty DataFrame, then add rows, one by one?

I created an empty DataFrame:

JavaScript

Then I can add a new row at the end and fill a single field with:

JavaScript

It works for only one field at a time. What is a better way to add new row to df?

Advertisement

Answer

You can use df.loc[i], where the row with index i will be what you specify it to be in the dataframe.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement