我有一个数据框,我根据一列的值(正数或负数)划分为2个子集。
我们假设一列包含以下值:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=API_KEY_HERE"></script>
我基本上想在每个子集中创建一个列来计算一个值和前一个值之间的差异。所以它会给出类似这样的内容:
1
4
9
2
1
然后我只想将值移到上面一行。我使用下面的代码,最后给出了结果,但我总是得到这个警告,我不明白。 &#34;尝试在DataFrame的切片副本上设置值。 尝试使用.loc [row_indexer,col_indexer] = value而不是#34; 你能帮忙吗?
n/a
3
5
-7
-1
答案 0 :(得分:2)
This warning is just letting you know that you may be modifying a copy of a df and not the original. In my experience, it's often a false positive. If you find this to be the case for you as well, you can turn off the warning.
For more information, see this post, and especially the links @Garrett provided.