How to append new data in pandas DataFrame

0 votes

Hi Guys,

I have one Pandas DataFrame. I want to append new data in this DataFrame. Can anyone tell me how can I do this?

Jun 22, 2020 in Python by MD
• 95,180 points
114 views

1 answer to this question.

0 votes

Hi@MD,

You can use the append function to add new data in your DataFrame. You can go through the below example.

df1 = pd.DataFrame({"x":[25,15,12,19],"y":[47, 24, 17, 29]}) 
df2 = pd.DataFrame({"x":[25, 15, 12],"y":[47, 24, 17],"z":[38, 12, 45]}) 
df1.append(df2, ignore_index = True)   
x y z
0 25 47 NaN
1 15 24 NaN
2 12 17 NaN
3 19 29 NaN
4 25 47 38.0
5 15 24 12.0
6 12 17 45.0

I hope this will help you.

answered Jun 22, 2020 by akhtar
• 38,170 points

Related Questions In Python

0 votes
1 answer

How to change data types in Pandas DataFrame?

Hi@akhtar, You can use astype function to change ...READ MORE

answered Jun 22, 2020 in Python by MD
• 95,180 points
292 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 58,120 points
8,104 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,520 points
27,808 views
0 votes
1 answer

How to find an element in Pandas Dataframe?

You can do it like this: Suppose df is ...READ MORE

answered Apr 8, 2019 in Python by Tina
20,755 views
0 votes
1 answer

How to find if a value exists in Pandas dataframe?

Try this:​ for name in df['Name']: ...READ MORE

answered Apr 8, 2019 in Python by Tina
9,646 views
0 votes
1 answer
0 votes
1 answer

How to create Pandas series from dictionary?

Here's a sample script: import pandas as pd import ...READ MORE

answered Apr 1, 2019 in Python by Prateek
946 views
0 votes
1 answer

How to create Pandas series from numpy array?

Hi. Refer to the below command: import pandas ...READ MORE

answered Apr 1, 2019 in Python by Pavan
1,710 views
0 votes
2 answers
0 votes
1 answer