Skip to content

Grouping over PeriodIndex breaks its format #2569

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
leonbaum opened this issue Dec 19, 2012 · 1 comment
Closed

Grouping over PeriodIndex breaks its format #2569

leonbaum opened this issue Dec 19, 2012 · 1 comment
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@leonbaum
Copy link

With the master branch (f014b01), grouping over a PeriodIndex is breaking the format of the index:

In [100]: df = pandas.DataFrame({'x': [1, 2, 3], 'y': ['2012-12-18', '2012-12-19', '2013-01-04']})

In [101]: df['y'] = df.y.astype('datetime64[D]')

In [102]: df = df.set_index('y').to_period('M')

In [103]: df
Out[103]: 
         x
2012-12  1
2012-12  2
2013-01  3

In [104]: df.groupby(level=0).sum()
Out[104]: 
     x
515  3
516  3

I would expect to still see the dates in the index.

@changhiskhan
Copy link
Contributor

Now Index(PeriodIndex) returns PeriodIndex if dtype is unspecified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

No branches or pull requests

3 participants