Repository: modin-project/modin

Issue:
TypeError: reset_index() got an unexpected keyword argument 'name'
<!--
General questions should be asked on the mailing list modin-dev@googlegroups.com.

Before submitting an issue, please fill out the following form.
-->

### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:
- **Modin installed from (source or binary)**:
- **Modin version**:
- **Python version**:
- **Exact command to reproduce**:

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

### 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. -->



Discussion:
Hi, we have the an identical API to pandas 0.23.4 and [`reset_index`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reset_index.html) does not take in the keyword argument `name`, which is likely the issue. However, if that is not the issue please provide a code sample and I'll look more into the issue.
Hi. I encountered this same error. Close look into the error revealed that reset_index() renamed index column from 'name' to index. See attached screenshot.
![reset_index](https://user-images.githubusercontent.com/20385376/56125218-1c327700-5f81-11e9-98ad-c4e89c32559f.png)

Hi @jaysnm, thank you so much for the clarification! This helps a lot.

This is the line: https://github.com/modin-project/modin/blob/master/modin/backends/pandas/query_compiler.py#L810. We should be checking that the index has a name first.

Resolving patch:
diff --git a/modin/backends/pandas/query_compiler.py b/modin/backends/pandas/query_compiler.py
--- a/modin/backends/pandas/query_compiler.py
+++ b/modin/backends/pandas/query_compiler.py
@@ -807,7 +807,13 @@ def reset_index(self, **kwargs):
                 result = self.data.from_pandas(index_data).concat(1, self.data)
                 return self.__constructor__(result, new_index, new_columns)
             else:
-                new_column_name = "index" if "index" not in self.columns else "level_0"
+                new_column_name = (
+                    self.index.name
+                    if self.index.name is not None
+                    else "index"
+                    if "index" not in self.columns
+                    else "level_0"
+                )
                 new_columns = self.columns.insert(0, new_column_name)
                 result = self.insert(0, new_column_name, self.index)
                 return self.__constructor__(result.data, new_index, new_columns)


Test patch:
diff --git a/modin/pandas/test/test_dataframe.py b/modin/pandas/test/test_dataframe.py
--- a/modin/pandas/test/test_dataframe.py
+++ b/modin/pandas/test/test_dataframe.py
@@ -5015,6 +5015,23 @@ def test_reset_index_with_multi_index(self, data):
 
             assert modin_cols.equals(pandas_cols)
 
+    def test_reset_index_with_named_index(self):
+        modin_df = pd.DataFrame(test_data_values[0])
+        pandas_df = pandas.DataFrame(test_data_values[0])
+
+        modin_df.index.name = pandas_df.index.name = "NAME_OF_INDEX"
+        df_equals(modin_df, pandas_df)
+        df_equals(modin_df.reset_index(drop=False), pandas_df.reset_index(drop=False))
+
+        modin_df.reset_index(drop=True, inplace=True)
+        pandas_df.reset_index(drop=True, inplace=True)
+        df_equals(modin_df, pandas_df)
+
+        modin_df = pd.DataFrame(test_data_values[0])
+        pandas_df = pandas.DataFrame(test_data_values[0])
+        modin_df.index.name = pandas_df.index.name = "NEW_NAME"
+        df_equals(modin_df.reset_index(drop=False), pandas_df.reset_index(drop=False))
+
     @pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
     def test_inplace_series_ops(self, data):
         pandas_df = pandas.DataFrame(data)