我正在尝试加入熊猫的两个数据集。我要做的是将df2.groupby('BuildingID')
的结果放入df1
中的一个新系列中。原因是building ID是我将要使用的级别,而ItemID是建筑中的项的集合。在
示例:
df1
BuildingID Blah ...
3 'a' ...
4 'b' ...
5 'c' ...
7 'd' ...
df2
ItemID BuildingID EnergyID ...
7 3 2 ...
11 3 11 ...
12 3 12 ...
13 4 2 ...
14 5 12 ...
15 4 10 ...
16 7 2 ...
17 7 3 ...
最后我要说的是:
^{pr2}$所以我的问题是1,我如何实现这一点,2,这是一个好主意还是有更好的方法来表示这些数据-也许每个组的所有标题都有后缀的标题?在
这可能有点取决于你下一步想做什么,但我会选择类似于:
相关问题 更多 >
编程相关推荐