How to append a list as a row to a Pandas DataFrame in Python? Last Updated : 02 Mar, 2023 Comments Improve Suggest changes Like Article Like Report Prerequisite: Pandas DataFrame In this article, We are going to see how to append a list as a row to a pandas dataframe in Python. It can be done in three ways: Using loc[]Using iloc[]Using append()Append list using loc[] methods Pandas DataFrame.loc attribute access a group of rows and columns by label(s) or a boolean array in the given DataFrame. Let's append the list with step-wise: Step 1: Create a simple dataframe using the list. Python3 import pandas as pd # List Person = [ ['Satyam', 21, 'Patna' , 'India' ], ['Anurag', 23, 'Delhi' , 'India' ], ['Shubham', 27, 'Coimbatore' , 'India' ]] #Create a DataFrame object df = pd.DataFrame(Person, columns = ['Name' , 'Age', 'City' , 'Country']) # display display(df) Output: Step 2: Using loc to append the new list to a data frame. Python3 # New list for append into df list = ["Saurabh", 23, "Delhi", "india"] # using loc methods df.loc[len(df)] = list # display display(df) Output: Append list using iloc[] methods Pandas DataFrame.iloc method access integer-location based indexing for selection by position. Example: Python3 # import module import pandas as pd # List Person = [ ['Satyam', 21, 'Patna' , 'India' ], ['Anurag', 23, 'Delhi' , 'India' ], ['Shubham', 27, 'Coimbatore' , 'India' ], ["Saurabh", 23, "Delhi", "india"]] #Create a DataFrame object df = pd.DataFrame(Person, columns = ['Name' , 'Age', 'City' , 'Country']) # new list to append into df list = ['Ujjawal', 22, 'Fathua', 'India'] # using iloc df.iloc[2] = list # display display(df) Output: Note - It is used for location-based indexing so it works for only the existing index and replaces the row element. Append list using append() methods Pandas dataframe.append() function is used to append rows of other dataframe to the end of the given dataframe, returning a new dataframe object. Example: Python3 # import module import pandas as pd # List Person = [ ['Satyam', 21, 'Patna' , 'India' ], ['Anurag', 23, 'Delhi' , 'India' ], ['Shubham', 27, 'Coimbatore' , 'India' ]] #Create a DataFrame object df = pd.DataFrame(Person, columns = ['Name' , 'Age', 'City' , 'Country']) # new list to append into df list = [["Manjeet", 25, "Delhi", "india"]] # using append df = df.append(pd.DataFrame( list, columns=[ 'Name', 'Age', 'City', 'Country']), ignore_index = True) # display df display(df) Output: Time complexity: Appending a dataframe to another dataframe is a constant time operation, as it requires only the addition of one row (or multiple rows) to the existing dataframe. Hence the time complexity of this operation is O(1). Space complexity: The space complexity of this operation is also O(1), as it only requires the addition of one row of data to the existing dataframe. Comment More infoAdvertise with us Next Article How to append a list as a row to a Pandas DataFrame in Python? kumar_satyam Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Python-pandas Python pandas-dataFrame Python Pandas-exercise +2 More Practice Tags : python Similar Reads How to Convert a List to a DataFrame Row in Python? In this article, we will discuss how to convert a list to a dataframe row in Python. Method 1: Using T function This is known as the Transpose function, this will convert the list into a row. Here each value is stored in one column. Syntax: pandas.DataFrame(list).T Example: Python3 # import pandas m 3 min read Select any row from a Dataframe in Pandas | Python In this article, we will learn how to get the rows from a dataframe as a list, without using the functions like ilic[]. There are multiple ways to do get the rows as a list from given dataframe. Letâs see them will the help of examples. Python3 # importing pandas as pd import pandas as pd # Create t 1 min read Append list of dictionary and series to a existing Pandas DataFrame in Python In this article, we will discuss how values from a list of dictionaries or Pandas Series can be appended to an already existing pandas dataframe. For this purpose append() function of pandas, the module is sufficient. Syntax: DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=N 2 min read Create a list from rows in Pandas DataFrame | Set 2 In an earlier post, we had discussed some approaches to extract the rows of the dataframe as a Python's list. In this post, we will see some more methods to achieve that goal. Note : For link to the CSV file used in the code, click here. Solution #1: In order to access the data of each row of the Pa 2 min read How to Copy a Pandas DataFrame Row to Multiple Other Rows? To copy a row from a Pandas DataFrame to multiple other rows, combination of copy() and loc[] methods are used more oftem. The copy() method creates a new copy of the row. Let's discuss all the methods with quick examples:Method 1: Using loc and copyThis method involves selecting a specific row usin 3 min read Add a row at top in pandas DataFrame Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Let's see how can we can add a row at top in pandas DataFrame.Observe this dataset first. Python3 # importing pandas module import pandas as pd # making data fram 1 min read How to Convert Pandas DataFrame into a List? In this article, we will explore the process of converting a Pandas DataFrame into a List, We'll delve into the methods and techniques involved in this conversion, shedding light on the versatility and capabilities of Pandas for handling data structures in Python.Ways to convert Pandas DataFrame Int 7 min read Create a list from rows in Pandas dataframe Python lists are one of the most versatile data structures, offering a range of built-in functions for efficient data manipulation. When working with Pandas, we often need to extract entire rows from a DataFrame and store them in a list for further processing. Unlike columns, which are easily access 4 min read How to add header row to a Pandas Dataframe? A header necessarily stores the names or headings for each of the columns. It helps the user to identify the role of the respective column in the data frame. The top row containing column names is called the header row of the data frame. There are two approaches to add header row to a Pandas Datafra 4 min read Like