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
Using reset_index() after the group by will do the trick:
df = pd.DataFrame({'a': [1, 1, 3],
'b': [4.0, 5.5, 6.0],
'c': ['7L', '8L', '9L'],
'name': ['hello', 'hello', 'foo']})
df.groupby(['a', 'name']).median().reset_index().name
here is the result:
0 hello
1 foo
Name: name, dtype: object
and if you want the list of the values, you can simply:
df = pd.DataFrame({'a': [1, 1, 3],
'b': [4.0, 5.5, 6.0],
'c': ['7L', '8L', '9L'],
'name': ['hello', 'hello', 'foo']})
df.groupby(['a', 'name']).median().reset_index().name.values
The result of using values will be a list containing the values for the name column. The code above returns the following list as the results:
array(['hello', 'foo'], dtype=object)