【发布时间】:2021-09-27 18:17:56
【问题描述】:
我很难找到一个直截了当的答案。我想要做的是获取具有 125 的 Keycode 列值的行和具有 175 的 Keycode 列值的行,并将它们放入 1 个数据框中。我认为它会是这样的,但我的想法是不正确的。我只将 125 输出到数据框。提前感谢您的任何帮助或称我为无脑...
groups = df.groupby(df.Keycode) # Keycode is the column label I grouped on
onetwofive = groups.get_group('125') # 125 is the column value I'm wanting to pull out
onetwofive.append(groups.get_group('175')) # 175 is the column value I'm wanting to pull out and append with the 125 group
【问题讨论】:
标签: python pandas dataframe pandas-groupby