In this article, we’ll see how to add a new row of values to an existing dataframe. This can be used when we want to insert a new entry in our data that we might have missed adding earlier. There are different methods to achieve this. Now let’s see with the help of examples how we can do this
We can add a single row using DataFrame.loc. We can add the row at the last in our dataframe. We can get the number of rows using len(DataFrame.index) for determining the position at which we need to add the new row.
We can also add a new row using the DataFrame.append() function
We can also add multiple rows using the pandas.concat() by creating a new dataframe of all the rows that we need to add and then appending this dataframe to the original dataframe.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Adding new column to existing DataFrame in Pandas
- Create a new column in Pandas DataFrame based on the existing columns
- Add a row at top in pandas DataFrame
- Python | Change column names and row indexes in Pandas DataFrame
- Apply function to every row in a Pandas DataFrame
- Select row with maximum and minimum value in Pandas dataframe
- Insert row at given position in Pandas Dataframe
- Select any row from a Dataframe in Pandas | Python
- Select any row from a Dataframe using iloc and iat in Pandas
- How to Sort a Pandas DataFrame based on column names or row index?
- Apply a function to each row or column in Dataframe using pandas.apply()
- Get the specified row value of a given Pandas DataFrame
- Get a specific row in a given Pandas DataFrame
- Python | Pandas DataFrame.fillna() to replace Null values in dataframe
- Pandas Dataframe.to_numpy() - Convert dataframe to Numpy array
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- Python | Pandas dataframe.add()
- How to add Empty Column to Dataframe in Pandas?
- Add column names to dataframe in Pandas
- Add multiple columns to dataframe in Pandas
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.