【发布时间】:2015-07-23 00:25:24
【问题描述】:
我正在尝试使用 Pandas,我需要解决以下问题。
我有一个数据集,其中的列如下所示:
X1 Y1 Z1 1.....(bunch of other columns)
X1 Y1 Z1 2.....(bunch of other columns)
X1 Y1 Z1 3.....(bunch of other columns)
X2 Y2 Z2 1.....(bunch of other columns)
X2 Y2 Z2 2.....(bunch of other columns)
X2 Y2 Z2 3.....(bunch of other columns)
X2 Y2 Z2 4.....(bunch of other columns)
我需要通过将前三列作为键来处理数据集。所以我需要首先考虑与X1 Y1 Z1 关联的所有行,在其中处理一堆列,然后转到下一个块X2 Y2 Z2。所以首先它的
X1 Y1 Z1 1.....(bunch of other columns)
X1 Y1 Z1 2.....(bunch of other columns)
X1 Y1 Z1 3.....(bunch of other columns)
紧随其后
X2 Y2 Z2 1.....(bunch of other columns)
X2 Y2 Z2 2.....(bunch of other columns)
X2 Y2 Z2 3.....(bunch of other columns)
X2 Y2 Z2 4.....(bunch of other columns)
我正在寻找 pandas 或 numpy 中的解决方案来处理此数据集。而且我处理数百万行,所以 pandas 的 iterrows() 会很慢。
【问题讨论】:
标签: python numpy pandas bigdata