modin icon indicating copy to clipboard operation
modin copied to clipboard

groupby(level=0) leads to TypeError: 'NoneType' object is not iterable

Open izdi opened this issue 7 years ago • 1 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS Mojave 10.14.3 (18D109)
  • Modin installed from (source or binary): pip
  • Modin version: 0.4.0
  • Python version: 3.7.0
  • Exact command to reproduce: df.groupby(level=0)

Describe the problem

Using df.grouby(level=0) to group by index using level param causes error

Source code / logs

import modin.pandas as pd
import numpy as np

test_data = pd.DataFrame({
    'A': 1,
    'B': np.array([3] * 4, dtype='int32')
})
test_data.groupby(level=0)

TypeError Traceback (most recent call last) in () 6 'B': np.array([3] * 4, dtype='int32') 7 }) ----> 8 test_data.groupby(level=0)

~/.pyenv/versions/3.7.0/envs/topic-modeling/lib/python3.7/site-packages/modin/pandas/dataframe.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, **kwargs) 407 idx_name, 408 observed=observed, --> 409 **kwargs 410 ) 411

~/.pyenv/versions/3.7.0/envs/topic-modeling/lib/python3.7/site-packages/modin/pandas/groupby.py in init(self, df, by, axis, level, as_index, sort, group_keys, squeeze, idx_name, **kwargs) 42 self._by = by 43 # This tells us whether or not there are multiple columns/rows in the groupby ---> 44 self._is_multi_by = all(obj in self._df for obj in self._by) and axis == 0 45 self._level = level 46 self._kwargs = {

TypeError: 'NoneType' object is not iterable

izdi avatar Apr 24 '19 15:04 izdi

Hi @izdi thanks for posting!

I can reproduce this issue on the current master, and the fix is relatively simple. I will be able to fix it today, thanks!

devin-petersohn avatar Apr 24 '19 16:04 devin-petersohn