Skip to content

grouby( ... , as_index=False) convert "float64" to "object" type. #3610

Closed
@ronenabr

Description

@ronenabr
In [1]: import pandas as pd 

In [2]: df = pd.DataFrame({"c1" : [1,2,6,6,8]})

In [3]: df["c2"] = df.c1/2.0

In [4]: df.groupby("c2").mean().reset_index().c2
Out[4]: 
0    0.5
1    1.0
2    3.0
3    4.0
Name: c2, dtype: float64

In [5]: df.groupby("c2", as_index=False).mean().c2
Out[5]: 
0    0.5
1      1
2      3
3      4
Name: c2, dtype: object

Note the difference in dtype between the two cases.
I think the 2nd case shouldn't be different then the 1st case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions