How to append new row to dataframe in pandas?

前端 未结 4 824
臣服心动
臣服心动 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:12

    Use -

    iname = "name1"    
    ipassword = "password1"
    iemail = "email@domain.com"
    
    df2 = df.append(pd.DataFrame([[iname,ipassword,iemail]], columns
    =df.columns))
    df2.to_csv("login.csv", index=False)
    

    Output

        name   password             email
    0  admin      admin             asdfs
    1    zds         sd          dsssfsfd
    2  vipul        rao           dsfdsfs
    0  name1  password1  email@domain.com
    

提交回复
热议问题