正如我们所知
if inplace is False
Assign to a new variable;
else
No need to assign
在inplace== false
的情况下 变量是副本还是具有引用哪个点相同的数据集?
它是一个副本。您可以尝试:
>>> import pandas as pd
>>> df = pd.DataFrame({'a':[1,2,3], 'b':[4,5,6]})
>>> df2 = df.drop('b', axis=1, inplace=False)
>>> df2
a
0 1
1 2
2 3
>>> df
a b
0 1 4
1 2 5
2 3 6
当in_place = True
数据在原始位置重命名时。
而
如果使用in_place = False
,则在执行所需操作后将返回数据的副本。