设置索引时熊猫设置带有复制警告

时间:2019-03-04 16:48:44

标签: pandas

我尝试根据现有列在pandas数据框中设置索引

df具有col1,col2,col3,col4。 我写道:

df = df.set_index(['col1','col2','col3'], drop=False, inplace=True)

我得到:

SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

如果只是警告,我会没事的,但是我什至无法访问df。

df.shape:

'NoneType' object has no attribute 'shape'

0 个答案:

没有答案