Skip to content

pandas.core.groupby.DataFrameGroupBy should provide a method to be converted into a (MultiIndex) DataFrame #4883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
c0indev3l opened this issue Sep 19, 2013 · 2 comments

Comments

@c0indev3l
Copy link

>>> df1 = pd.DataFrame( { 
    "Name" : ["Alice", "Bob", "Mallory", "Mallory", "Bob" , "Mallory"] , 
    "City" : ["Seattle", "Seattle", "Portland", "Seattle", "Seattle", "Portland"] } )

>>> g1 = df1.groupby( [ "Name" ] )

>>> print g1.head()
               City     Name
Name                        
Alice   0   Seattle    Alice
Bob     1   Seattle      Bob
        4   Seattle      Bob
Mallory 2  Portland  Mallory
        3   Seattle  Mallory
        5  Portland  Mallory

>>>> pd.DataFrame(g1)

raise exception
AttributeError: 'numpy.ndarray' object has no attribute 'index'

@jreback
Copy link
Contributor

jreback commented Sep 19, 2013

pls have a look at the docs, a GroupBy object is only an intermediary step. you need to apply something to it. http://pandas.pydata.org/pandas-docs/dev/groupby.html

maybe you are looking for set_index?

@jreback
Copy link
Contributor

jreback commented Sep 22, 2013

closing as not a bug

@jreback jreback closed this as completed Sep 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants