Repository: modin-project/modin

Issue:
ValueError: Grouper for 'passenger_count' not 1-dimensional in nyc-taxi.py
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: `Windows 10`
- **Modin version** (`modin.__version__`): `0.8.2.1`
- **Python version**: `Python 3.7.8`
- **Code we can use to reproduce**:

```python
python examples/docker/nyc-taxi.py
```

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

Queries are outdated - we need to sync them with omniscripts.

### Source code / logs
<!-- Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem. -->

```shell
Traceback (most recent call last):
  File "nyc-taxi.py", line 73, in <module>
    main()
  File "nyc-taxi.py", line 69, in main
    measure('Q3', q3, df)
  File "nyc-taxi.py", line 60, in measure
    res = func(*args, **kw)
  File "nyc-taxi.py", line 47, in q3
    return transformed.groupby(["pickup_datetime", "passenger_count"]).agg({"passenger_count": ["count"]})
  File "modin/pandas/groupby.py", line 400, in aggregate
    drop=self._drop,
  File "modin/backends/base/query_compiler.py", line 1439, in groupby_dict_agg
    drop=drop,
  File "modin/data_management/functions/default_methods/default.py", line 76, in args_cast
    return wrapper(self, *args, **kwargs)
  File "modin/data_management/functions/default_methods/default.py", line 92, in wrapper
    return self.default_to_pandas(fn, *args, **kwargs)
  File "modin/backends/pandas/query_compiler.py", line 222, in default_to_pandas
    result = pandas_op(self.to_pandas(), *args, **kwargs)
  File "modin/data_management/functions/default_methods/default.py", line 40, in applyier
    result = fn(df, *args, **kwargs)
  File "modin/data_management/functions/default_methods/groupby_default.py", line 81, in fn
    grp = df.groupby(by, axis=axis, **groupby_args)
  File "pandas/core/frame.py", line 6525, in groupby
    dropna=dropna,
  File "pandas/core/groupby/groupby.py", line 533, in __init__
    dropna=self.dropna,
  File "pandas/core/groupby/grouper.py", line 814, in get_grouper
    if not isinstance(gpr, Grouping)
  File "pandas/core/groupby/grouper.py", line 517, in __init__
    raise ValueError(f"Grouper for '{t}' not 1-dimensional")
ValueError: Grouper for 'passenger_count' not 1-dimensional
```



Discussion:

Resolving patch:
diff --git a/examples/docker/nyc-taxi.py b/examples/docker/nyc-taxi.py
--- a/examples/docker/nyc-taxi.py
+++ b/examples/docker/nyc-taxi.py
@@ -40,19 +40,14 @@ def q2(df):
     return df.groupby("passenger_count", as_index=False).mean()[["passenger_count", "total_amount"]]
 
 def q3(df):
-    transformed = pd.DataFrame({
-        "passenger_count": df["passenger_count"],
-        "pickup_datetime": df["pickup_datetime"].dt.year,
-    })
-    return transformed.groupby(["pickup_datetime", "passenger_count"]).agg({"passenger_count": ["count"]})
+    df["pickup_datetime"] = df["pickup_datetime"].dt.year
+    return df.groupby(["pickup_datetime", "passenger_count"]).size().reset_index()
+
 
 def q4(df):
-    transformed = pd.DataFrame({
-        "passenger_count": df["passenger_count"],
-        "pickup_datetime": df["pickup_datetime"].dt.year,
-        "trip_distance": df["trip_distance"].astype("int64"),
-    })
-    return transformed.groupby(["passenger_count", "pickup_datetime", "trip_distance"])  \
+    df["pickup_datetime"] = df["pickup_datetime"].dt.year
+    df["trip_distance"] = df["trip_distance"].astype("int64")
+    return df.groupby(["passenger_count", "pickup_datetime", "trip_distance"])  \
             .size().reset_index().sort_values(by=["pickup_datetime", 0], ascending=[True, False])
 
 def measure(name, func, *args, **kw):
@@ -66,8 +61,8 @@ def main():
     df = measure('Reading', read)
     measure('Q1', q1, df)
     measure('Q2', q2, df)
-    measure('Q3', q3, df)
-    measure('Q4', q4, df)
+    measure('Q3', q3, df.copy())
+    measure('Q4', q4, df.copy())
 
 if __name__ == '__main__':
     main()


Test patch: