import pandas as pd
df_run = pd.read_csv('UserEventSummary.csv')
df_run.accountId[0] = 'first-' + str(df_run.accountId[0])
第三行给出了以下错误:
/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/ipykernel/__main__.py:1: 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
if __name__ == '__main__':
/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/pandas/core/indexing.py:194: 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
self._setitem_with_indexer(indexer, value)
我已经阅读了有关这方面的文档,并对何时发生这种情况有了很好的理解,但不太清楚为什么要在这里找到它。我不觉得我做错了什么或做了什么危险的事!?
我猜还有更好(更正确)的方法来做这件事?
https://stackoverflow.com/questions/54030650
复制相似问题