How to add a row of data in pandas & modify the value of a column according to the value of a column

How to add a row of data

Method 1:
print( df.append (row,ignore_index=True))

Method 2:
a, b, c, d are the attribute values ​​of the column, and the quantity must match

df.loc[index] = [a,b,c,d]

Reference document: https://blog.csdn.net/haodawei123/article/details/125586845

Modify the value of a column according to the value of a column

import pandas as pd
x2 = pd.read_csv("submit.csv")
x2.loc[x2.id==800000,'isDefault'] = 1
x2

Reference document: https://codeleading.com/article/79325488189/

Guess you like

Origin blog.csdn.net/xiaoyurainzi/article/details/130200423