You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pandas as pd
df = pd.DataFrame({'a': [1,2,3,4], 'b':[None, None, None, None]})
chunks = df.groupby('a')
assert len([g for g, chunk in chunks]) == 4
chunks = df.groupby(['a', 'b'])
# failed here, it's emtpy
assert len([g for g, chunk in chunks]) == 4
# however, chunks.groups shows that there are 4 groups
#{(1, nan): [0], (2, nan): [1], (3, nan): [2], (4, nan): [3]}
# but if we fillna('') first then it could pass
chunks = df.fillna('').groupby(['a', 'b'])
assert len([g for g, chunk in chunks]) == 4
# In[11]:
Expected Output
I don't see why have NaN in the grouped by key should fail the groupby. Especially if you use chunks.groups, you do have them grouped like this {(1, nan): [0], (2, nan): [1], (3, nan): [2], (4, nan): [3]} In [18]:
Code Sample, a copy-pastable example if possible
Expected Output
I don't see why have NaN in the grouped by key should fail the groupby. Especially if you use
chunks.groups
, you do have them grouped like this{(1, nan): [0], (2, nan): [1], (3, nan): [2], (4, nan): [3]} In [18]:
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: