且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python,Pandas从计算中添加列

更新时间:2023-12-01 10:05:28

您需要 副本

df1 = df[df['name_code'].isin(wanted)].copy()

如果以后修改 df1 中的值,您会发现修改不会传播回原始数据( df ),而熊猫会警告。

If you modify values in df1 later you will find that the modifications do not propagate back to the original data (df), and that Pandas does warning.