我试图通过索引选择设置数据框中的列的值.
myindex = (df['city']==old_name) & (df['dt'] >= startDate) & (df['dt'] < endDate)
new_name = 'Boston2
df['proxyCity'].ix[myindex ] = new_name
Run Code Online (Sandbox Code Playgroud)
在上面,我想在myindex中给定条件Boston2的proxyCity列中分配值
C:\Users\blah\Anaconda3\lib\site-packages\pandas\core\indexing.py:132: 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)
Run Code Online (Sandbox Code Playgroud)
在没有引入文档中概述的问题的情况下,做我想做的事情的正确方法是什么.
使用pandas选择以多个等价条件为条件的行的链接中的答案似乎就像我实现它一样.
我不确定这样做的正确方法是什么.