How to add row to pandas DataFrame in Python

1 Answer

0 votes
import pandas as pd

dict = {'name': ['Tom', 'Emmy', 'Axel'],
	    'algebra': [91, 80, 94],
	    'python': [98, 85, 96]}

df = pd.DataFrame(dict)
new_row = {'name':'Fox', 'algebra':85, 'python':89}
df = df.append(new_row, ignore_index=True)
print(df)
    


'''
run

names  algebra  python
0   Tom       91      98
1  Emmy       80      85
2  Axel       94      96
3   Fox       85      89

'''

 



answered Dec 31, 2020 by avibootz

Related questions

1 answer 165 views
2 answers 281 views
1 answer 114 views
1 answer 239 views
...