pandas 对指定列做fillna

1
2
df.fillna({'code':'code', 'date':'date'})
df.[["code", "date"]].fillna("")

pandas 指定列重命名

1
df.rename(columns={"amount": "total_amount"}, inplace=True)

DataFrame 按直接列left join合并

1
df = pd.merge(df_1, df_2, on=["code", "date"], how='left')

DataFrame 两列相加相减

1
2
df["amount"] = df["total_amount"] - df["amount"]
df["amount"] = df["total_amount"] + df["amount"]