0
我有一個數據框,並應用了groupby方法。現在我有一個pandas.core.groupby.SeriesGroupBy,但我不能使用任何數據框方法。我怎樣才能將它轉換爲可用的數據框?將pandas.core.groupby.SeriesGroupBy轉換爲dataframe
type(survivor)
pandas.core.groupby.SeriesGroupBy
應用.groups它看起來像這樣:
{'C': Int64Index([ 1, 9, 19, 26, 30, 31, 34, 36, 39, 42,
847, 849, 852, 858, 859, 866, 874, 875, 879, 889],
dtype='int64', name=u'ID', length=168),
'Q': Int64Index([ 5, 16, 22, 28, 32, 44, 46, 47, 82, 109, 116, 126,
143,
156, 171, 186, 188, 196, 198, 208, 214, 241, 245, 260, 264, 274,
727, 749, 767, 768, 776, 778, 787, 790, 825, 828, 885, 890],
dtype='int64', name=u'ID'),
'S': Int64Index([ 0, 2, 3, 4, 6, 7, 8, 10, 11, 12,
877, 878, 880, 881, 882, 883, 884, 886, 887, 888],
dtype='int64', name=u'ID', length=644)}
我曾嘗試以下的一些相關的其他問題的指示,但仍然得到同樣的錯誤(例如): AttributeError的:「SeriesGroupBy '對象沒有屬性'set_index'
非常感謝!