How to append new row to dataframe in pandas?

前端 未结 4 830
臣服心动
臣服心动 2021-02-13 19:29

This is the code i have used

    iname = \"name1\"    
    ipassword = \"password1\"
    iemail = \"email@domain.com\"
    res1 = []
            


        
4条回答
  •  爱一瞬间的悲伤
    2021-02-13 20:09

    A good way is to create an empty list first, populate it and then add to the empty data frame like this

    data=[]
    
    for i, row in new_df.head(4).iterrows():
        sequence=str(row['body'])
        author=row['author']
        data.append([author,sequence]) 
    d=pd.DataFrame(data,columns = ['author', 'results'])
    

    it will give the results like this

提交回复
热议问题