Repository: modin-project/modin

Issue:
Series.reset_index does not consider 'name' parameter
### System information
- **OS Platform and Distribution**: Linux Ubuntu 16.04
- **Modin version** : 0.7.3
- **Python version**: 3.6.7
- **Code we can use to reproduce**:
```
Create dummy.csv with following content: 
a,b,c,
1,2,3
4,5,6

if __name__ == "__main__":
    import modin.pandas as mpd
    df=mpd.read_csv("dummy.csv", sep=",")
    df_count = df.groupby(["a", "b"]).size().reset_index(name="Count")
    print(df_count.columns)

    import pandas as pd
    df=pd.read_csv("dummy.csv", sep=",")
    df_count = df.groupby(["a", "b"]).size().reset_index(name="Count")
    print(df_count.columns)
```
### Describe the problem
Multi-column grouping loses the column names. Output of the code snippet:
Index(['level_0', 'level_1', 'Count'], dtype='object')
Index(['a', 'b', 'Count'], dtype='object')




Discussion:
Hi @isilopekel thanks for the report!

This issue is due to `groupby.size` not being implemented. We have a start on this, it will be in the next release.

Normally we would return a `modin.pandas.Series`, but this will return a `pandas.Series` object because it is very old code from before the `Series` implementation.

Link to `groupby.size` implementation: https://github.com/modin-project/modin/blob/985adb019e8586b2d666eebc1888c68e4035e8b7/modin/pandas/groupby.py#L365-L366

It seems that the problem here is not in groupby at all, but in `reset_index`. It seems that it does not consider custom `name`
```
if __name__ == "__main__":
    import pandas
    import modin.pandas as pd
    
    md_sr, pd_sr = pd.Series([1, 2, 3, 4]), pandas.Series([1, 2, 3, 4])

    print(md_sr.reset_index(name="Custom name").columns) # Index(['index', 0], dtype='object')
    print(pd_sr.reset_index(name="Custom name").columns) # Index(['index', 'Custom name'], dtype='object')
```

Resolving patch:
diff --git a/modin/pandas/series.py b/modin/pandas/series.py
--- a/modin/pandas/series.py
+++ b/modin/pandas/series.py
@@ -1235,7 +1235,6 @@ def reset_index(self, level=None, drop=False, name=None, inplace=False):
             else:
                 result = self.copy()
                 result.index = new_idx
-                result.name = name or self.name
                 return result
         elif not drop and inplace:
             raise TypeError(
@@ -1247,9 +1246,7 @@ def reset_index(self, level=None, drop=False, name=None, inplace=False):
                 obj.name = name
             from .dataframe import DataFrame
 
-            return DataFrame(self.copy()).reset_index(
-                level=level, drop=drop, inplace=inplace
-            )
+            return DataFrame(obj).reset_index(level=level, drop=drop, inplace=inplace)
 
     def rdivmod(self, other, level=None, fill_value=None, axis=0):
         return self._default_to_pandas(


Test patch:
diff --git a/modin/pandas/test/test_series.py b/modin/pandas/test/test_series.py
--- a/modin/pandas/test/test_series.py
+++ b/modin/pandas/test/test_series.py
@@ -2409,20 +2409,17 @@ def test_resample(closed, label, level):
 
 @pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
 @pytest.mark.parametrize("drop", [True, False], ids=["True", "False"])
-def test_reset_index(data, drop):
-    modin_series, pandas_series = create_test_series(data)
-    df_equals(modin_series.reset_index(drop=drop), pandas_series.reset_index(drop=drop))
-
-    modin_series_cp = modin_series.copy()
-    pandas_series_cp = pandas_series.copy()
-    try:
-        pandas_result = pandas_series_cp.reset_index(drop=drop, inplace=True)
-    except Exception as e:
-        with pytest.raises(type(e)):
-            modin_series_cp.reset_index(drop=drop, inplace=True)
-    else:
-        modin_result = modin_series_cp.reset_index(drop=drop, inplace=True)
-        df_equals(pandas_result, modin_result)
+@pytest.mark.parametrize("name", [None, "Custom name"])
+@pytest.mark.parametrize("inplace", [True, False])
+def test_reset_index(data, drop, name, inplace):
+    eval_general(
+        *create_test_series(data),
+        lambda df, *args, **kwargs: df.reset_index(*args, **kwargs),
+        drop=drop,
+        name=name,
+        inplace=inplace,
+        __inplace__=inplace,
+    )
 
 
 @pytest.mark.skip(reason="Using pandas Series.")
diff --git a/modin/pandas/test/utils.py b/modin/pandas/test/utils.py
--- a/modin/pandas/test/utils.py
+++ b/modin/pandas/test/utils.py
@@ -557,10 +557,12 @@ def check_df_columns_have_nans(df, cols):
     )
 
 
-def eval_general(modin_df, pandas_df, operation, comparator=df_equals, **kwargs):
+def eval_general(
+    modin_df, pandas_df, operation, comparator=df_equals, __inplace__=False, **kwargs
+):
     md_kwargs, pd_kwargs = {}, {}
 
-    def execute_callable(fn, md_kwargs={}, pd_kwargs={}):
+    def execute_callable(fn, inplace=False, md_kwargs={}, pd_kwargs={}):
         try:
             pd_result = fn(pandas_df, **pd_kwargs)
         except Exception as e:
@@ -569,7 +571,7 @@ def execute_callable(fn, md_kwargs={}, pd_kwargs={}):
                 repr(fn(modin_df, **md_kwargs))
         else:
             md_result = fn(modin_df, **md_kwargs)
-            return md_result, pd_result
+            return (md_result, pd_result) if not __inplace__ else (modin_df, pandas_df)
 
     for key, value in kwargs.items():
         if callable(value):
@@ -585,7 +587,9 @@ def execute_callable(fn, md_kwargs={}, pd_kwargs={}):
         md_kwargs[key] = md_value
         pd_kwargs[key] = pd_value
 
-    values = execute_callable(operation, md_kwargs=md_kwargs, pd_kwargs=pd_kwargs)
+    values = execute_callable(
+        operation, md_kwargs=md_kwargs, pd_kwargs=pd_kwargs, inplace=__inplace__
+    )
     if values is not None:
         comparator(*values)