Back
So I have initialized an empty pandas DataFrame and I would like to iteratively append lists (or Series) as rows in this DataFrame. What is the best way of doing this?
Just, create the DataFrame:.
import pandas as pd simple_list=[['a','b']] simple_list.append(['e','f']) df=pd.DataFrame(simple_list,columns=['col1','col2']) col1 col20 a b1 e f
import pandas as pd
simple_list=[['a','b']]
simple_list.append(['e','f'])
df=pd.DataFrame(simple_list,columns=['col1','col2'])
col1 col2
0 a b
1 e f
If you want to learn more about Pandas then visit this Python Course designed by the industrial experts.
31k questions
32.8k answers
501 comments
693 users