How to select columns from groupby object in pandas?

前端 未结 4 1976
甜味超标
甜味超标 2021-02-04 00:01

I grouped my dataframe by the two columns below

df = pd.DataFrame({\'a\': [1, 1, 3],
                   \'b\': [4.0, 5.5, 6.0],
                   \'c\': [7L, 8L         


        
4条回答
  •  故里飘歌
    2021-02-04 00:03

    Set as_index = False during groupby

    df = pandas.DataFrame({"a":[1,1,3], "b":[4,5.5,6], "c":[7,8,9], "name":["hello","hello","foo"]})
    df.groupby(["a", "name"] , as_index = False).median()
    

提交回复
热议问题