如何在熊猫中切片数据框并创建单独的数据框

时间:2018-12-06 07:04:34

标签: python-3.x pandas

我有一个关于如何切片数据帧并将数据帧存储为单独对象的简单问题。

例如,我拥有数据帧df,然后我做到了:

subset = df.iloc[0:5,]

但是我得到了错误:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py:3781: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  return super(DataFrame, self).rename(**kwargs)

0 个答案:

没有答案