Skip to content
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

BUG: resample/groupby with NaT in the grouper #7227

Closed
jreback opened this issue May 24, 2014 · 2 comments · Fixed by #7373
Closed

BUG: resample/groupby with NaT in the grouper #7227

jreback opened this issue May 24, 2014 · 2 comments · Fixed by #7373
Labels
Bug Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented May 24, 2014

related to this: #6992

These are broken

In [70]: df.set_index('A').resample('M',how='count')
ValueError: month must be in 1..12

In [73]: df.groupby(pd.Grouper(freq='MS',key='A')).count()
ValueError: month must be in 1..12

Separately, this should not also return the A column

In [74]: df.dropna(how='any',subset=['A']).groupby(pd.Grouper(key='A',freq='M')).count()
Out[74]: 
            A  B
A               
2014-10-31  3  3
2014-11-30  2  2
2014-12-31  1  1
In [57]: data
Out[57]: 
0   2014-10-01
1   2014-10-01
2   2014-10-31
3   2014-11-15
4   2014-11-30
5          NaT
6   2014-12-01
dtype: datetime64[ns]

In [58]: df = DataFrame(dict(A = data, B = np.arange(len(data))))

This is a work-around

In [59]: df.dropna(how='any',subset=['A']).set_index('A').resample('M',how='count')
Out[59]: 
            B
A            
2014-10-31  3
2014-11-30  2
2014-12-31  1
@jreback jreback added this to the 0.14.1 milestone May 24, 2014
@cpcloud
Copy link
Member

cpcloud commented May 24, 2014

Is this only with count?

@jreback
Copy link
Contributor Author

jreback commented May 24, 2014

I don't think so; I think its an issue with the NaT in the grouping itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Groupby Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants