从pandas中的相同列值中提取值数组

时间:2018-05-16 16:55:09

标签: python arrays pandas dataframe subset

我正在用熊猫提高知识,但我现在遇到了问题。 我有这个DataFrame结构。 主要是我想基于相同的Lat / Lon点提取PrpSummed数组。

         Year  Month   PrpSummed   Lat    Lon       Country
0        1980      1   46.877298 -34.5  -9.75  Saint Helena
7477     1980      2  204.177988 -34.5  -9.75  Saint Helena
14954    1980      3  117.243914 -34.5  -9.75  Saint Helena
22431    1980      4  374.656000 -34.5  -9.75  Saint Helena
29908    1980      5  177.617108 -34.5  -9.75  Saint Helena
37385    1980      6  151.473215 -34.5  -9.75  Saint Helena
44862    1980      7  388.515026 -34.5  -9.75  Saint Helena
52339    1980      8  221.093829 -34.5  -9.75  Saint Helena
59816    1980      9  264.000056 -34.5  -9.75  Saint Helena
67293    1980     10  132.107333 -34.5  -9.75  Saint Helena
74770    1980     11   62.275033 -34.5  -9.75  Saint Helena
82247    1980     12  166.834219 -34.5  -9.75  Saint Helena
89724    1981      1  167.100545 -34.5  -9.75  Saint Helena
97201    1981      2   57.451788 -34.5  -9.75  Saint Helena
104678   1981      3  142.887079 -34.5  -9.75  Saint Helena
112155   1981      4  118.741756 -34.5  -9.75  Saint Helena
...       ...    ...         ...   ...    ...           ...
3429697  2016      9  177.563373  37.5  51.00          Iran
3437747  2016     10  243.134902  37.5  51.00          Iran
3445797  2016     11  247.394538  37.5  51.00          Iran
3453847  2016     12  203.338263  37.5  51.00          Iran
3461897  2017      1  113.151845  37.5  51.00          Iran
3469947  2017      2  183.991026  37.5  51.00          Iran
3477997  2017      3  118.528012  37.5  51.00          Iran
3486047  2017      4  132.959934  37.5  51.00          Iran
3494097  2017      5   19.248508  37.5  51.00          Iran
3502147  2017      6    6.919063  37.5  51.00          Iran
3510197  2017      7   68.626854  37.5  51.00          Iran
3518247  2017      8    9.220729  37.5  51.00          Iran
3526297  2017      9  118.219854  37.5  51.00          Iran
3534347  2017     10  224.305352  37.5  51.00          Iran
3542397  2017     11  475.362162  37.5  51.00          Iran
3550447  2017     12  135.747279  37.5  51.00          Iran

此外,在此之后,我必须使用每个数组计算一些外部统计操作,然后在DataFrame中插入一个包含新月度统计数据的新列。有人可以帮帮我吗?

预期输出

arrayPrp = [
[46.877298,204.177988,117.243914,177.617108 ...],...,[177.563373,243.134902,247.394538,203.338263...]
 ]

最后

       Year  Month   PrpSummed   Lat    Lon       Country   SPI
0        1980      1   46.877298 -34.5  -9.75  Saint Helena 0.5
7477     1980      2  204.177988 -34.5  -9.75  Saint Helena 0.4
14954    1980      3  117.243914 -34.5  -9.75  Saint Helena 0.3
22431    1980      4  374.656000 -34.5  -9.75  Saint Helena 0.2
29908    1980      5  177.617108 -34.5  -9.75  Saint Helena 0.8
...

0 个答案:

没有答案