我有这样一个数据框:
+--------------+-------+-------+-------+-------+-------+-------+-------+
|Country/Region| 3/7/20| 3/8/20| 3/9/20|3/10/20|3/11/20|3/12/20|3/13/20|
+--------------+-------+-------+-------+-------+-------+-------+-------+
| Senegal| 0| 4| 10| 18| 27| 31| 35|
+--------------+-------+-------+-------+-------+-------+-------+-------+
| Tunisia| 1| 8| 15| 21| 37| 42| 59|
+--------------+-------+-------+-------+-------+-------+-------+-------+
对于每个国家,我都有一个独特的行,但我有许多列代表天。我想遍历每一列并从中减去前一列中的相应值,例如结果df应如下所示:
+--------------+-------+-------+-------+-------+-------+-------+-------+
|Country/Region| 3/7/20| 3/8/20| 3/9/20|3/10/20|3/11/20|3/12/20|3/13/20|
+--------------+-------+-------+-------+-------+-------+-------+-------+
| Senegal| 0| 4| 6| 8| 9| 4| 4|
+--------------+-------+-------+-------+-------+-------+-------+-------+
| Tunisia| 1| 7| 7| 6| 16| 5| 17|
+--------------+-------+-------+-------+-------+-------+-------+-------+
1条答案
按热度按时间2skhul331#
也许这是有帮助的-