Repository: modin-project/modin

Issue:
Creating a `modin.pandas.DataFrame` from a named index object drops the name
In the `modin.pandas.DataFrame` constructor, Modin will drop the name of the index object passed in, but in pandas, that name becomes the new column name. We probably need to special case the code to handle the named objects.

Script to reproduce:

```python
import modin.pandas as pd
# import pandas as pd
import pandas_market_calendars as mcal
import ray

ENTITIES = ['037833100', '594918104', '023135106', '30231G102', '478160104', '30303M102', '369604103', '00206R102',
            '46625H100', '742718109', '02079K305', '949746101', '931142103', '92343V104', '717081103', '084670702',
            '166764100', '191216100', '458140100', '58933Y105', '68389X105', '060505104', '20030N101', '437076102',
            '92826C839', '17275R102', '718172109', '713448108', '254687106', '459200101', '172967424', '91324P102',
            '031162100', '02209S103', '57636Q104', '88579Y101', '500754106', '806857108', '375558103', '00287Y109',
            '580135101', '126650100', '747525103', '110122108', '931427108', '532457108', '438516106', '913017109',
            '151020104', '097023105', '855244109', '907818108', '654106103', '911312106', '902973304', '741503403',
            '16119P108', '539830109', '882508104', '761713106', 'Y09827109', '38141G104', '609207105', '09062X103',
            '22160K105', '828806109', '194162103', '548661107', '026874784', '002824100', '617446448', '09247X101',
            '260543103', '025816109', '883556102', '887317303', '263534109', '65339F101', '293792107', '26441C204',
            '674599105', '235851102', '842587107', '00724F101', '26875P101', '37045V100', '79466L302', '872540109',
            '49456B101', '20825C104', '59156R108', '70450Y103', '149123101', '25746U109', '345370860', '03027X100',
            '369550108', '517834107', '61166W101', '693475105']


def main():
    nyse = mcal.get_calendar('NYSE')

    trade_date_range = nyse.valid_days(start_date='2016-12-20', end_date='2017-01-10')
    trade_date_range.name = "pricing_date"

    pricing_index = pd.MultiIndex.from_product([trade_date_range, ENTITIES], names=["pricing_date", "entity"])

    df = pd.DataFrame(index=pricing_index)

    # filtered_df = df.loc['2017-01-09'].index.get_level_values("entity")
    filtered_df = df._default_to_pandas(lambda x: x.loc['2017-01-09']).index.get_level_values("entity")
    dates_df = pd.DataFrame(df.index.get_level_values("pricing_date")).drop_duplicates().sort_values(by="pricing_date")
    # KeyError: "pricing_date" (not true in native Pandas) if we make the above call use _default_to_pandas
    # TypeError: '>=' not supported between instances of 'str' and 'int' if we leave the above as is
    print(dates_df.iloc[len(dates_df) // 2]["pricing_date"])


if __name__ == '__main__':
    ray.init()
    main()
```


Discussion:
Confirmed that this is reproducible on master!

Resolving patch:
diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py
--- a/modin/pandas/dataframe.py
+++ b/modin/pandas/dataframe.py
@@ -170,7 +170,9 @@ def __init__(
             warnings.warn(
                 "Distributing {} object. This may take some time.".format(type(data))
             )
-            if is_list_like(data) and not is_dict_like(data):
+            if isinstance(data, pandas.Index):
+                pass
+            elif is_list_like(data) and not is_dict_like(data):
                 old_dtype = getattr(data, "dtype", None)
                 values = [
                     obj._to_pandas() if isinstance(obj, Series) else obj for obj in data


Test patch:
diff --git a/modin/pandas/test/dataframe/test_iter.py b/modin/pandas/test/dataframe/test_iter.py
--- a/modin/pandas/test/dataframe/test_iter.py
+++ b/modin/pandas/test/dataframe/test_iter.py
@@ -27,7 +27,6 @@
     df_equals,
     test_data_values,
     test_data_keys,
-    create_test_dfs,
     test_data,
 )
 from modin.pandas.utils import SET_DATAFRAME_ATTRIBUTE_WARNING
@@ -338,70 +337,3 @@ def test_isin(data):
     modin_result = modin_df.isin(val)
 
     df_equals(modin_result, pandas_result)
-
-
-@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
-def test_constructor(data):
-    pandas_df = pandas.DataFrame(data)
-    modin_df = pd.DataFrame(data)
-    df_equals(pandas_df, modin_df)
-
-    pandas_df = pandas.DataFrame({k: pandas.Series(v) for k, v in data.items()})
-    modin_df = pd.DataFrame({k: pd.Series(v) for k, v in data.items()})
-    df_equals(pandas_df, modin_df)
-
-
-@pytest.mark.parametrize(
-    "data",
-    [
-        np.arange(1, 10000, dtype=np.float32),
-        [
-            pd.Series([1, 2, 3], dtype="int32"),
-            pandas.Series([4, 5, 6], dtype="int64"),
-            np.array([7, 8, 9], dtype=np.float32),
-        ],
-        pandas.Categorical([1, 2, 3, 4, 5]),
-    ],
-)
-def test_constructor_dtypes(data):
-    md_df, pd_df = create_test_dfs(data)
-    df_equals(md_df, pd_df)
-
-
-def test_constructor_columns_and_index():
-    modin_df = pd.DataFrame(
-        [[1, 1, 10], [2, 4, 20], [3, 7, 30]],
-        index=[1, 2, 3],
-        columns=["id", "max_speed", "health"],
-    )
-    pandas_df = pandas.DataFrame(
-        [[1, 1, 10], [2, 4, 20], [3, 7, 30]],
-        index=[1, 2, 3],
-        columns=["id", "max_speed", "health"],
-    )
-    df_equals(modin_df, pandas_df)
-    df_equals(pd.DataFrame(modin_df), pandas.DataFrame(pandas_df))
-    df_equals(
-        pd.DataFrame(modin_df, columns=["max_speed", "health"]),
-        pandas.DataFrame(pandas_df, columns=["max_speed", "health"]),
-    )
-    df_equals(
-        pd.DataFrame(modin_df, index=[1, 2]),
-        pandas.DataFrame(pandas_df, index=[1, 2]),
-    )
-    df_equals(
-        pd.DataFrame(modin_df, index=[1, 2], columns=["health"]),
-        pandas.DataFrame(pandas_df, index=[1, 2], columns=["health"]),
-    )
-    df_equals(
-        pd.DataFrame(modin_df.iloc[:, 0], index=[1, 2, 3]),
-        pandas.DataFrame(pandas_df.iloc[:, 0], index=[1, 2, 3]),
-    )
-    df_equals(
-        pd.DataFrame(modin_df.iloc[:, 0], columns=["NO_EXIST"]),
-        pandas.DataFrame(pandas_df.iloc[:, 0], columns=["NO_EXIST"]),
-    )
-    with pytest.raises(NotImplementedError):
-        pd.DataFrame(modin_df, index=[1, 2, 99999])
-    with pytest.raises(NotImplementedError):
-        pd.DataFrame(modin_df, columns=["NO_EXIST"])
diff --git a/modin/pandas/test/dataframe/test_map_metadata.py b/modin/pandas/test/dataframe/test_map_metadata.py
--- a/modin/pandas/test/dataframe/test_map_metadata.py
+++ b/modin/pandas/test/dataframe/test_map_metadata.py
@@ -1488,3 +1488,76 @@ def test_constructor_from_modin_series(get_index, get_columns, dtype):
         pandas_data, index=index, columns=columns, dtype=dtype
     )
     df_equals(new_modin, new_pandas)
+
+
+@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
+def test_constructor(data):
+    pandas_df = pandas.DataFrame(data)
+    modin_df = pd.DataFrame(data)
+    df_equals(pandas_df, modin_df)
+
+    pandas_df = pandas.DataFrame({k: pandas.Series(v) for k, v in data.items()})
+    modin_df = pd.DataFrame({k: pd.Series(v) for k, v in data.items()})
+    df_equals(pandas_df, modin_df)
+
+
+@pytest.mark.parametrize(
+    "data",
+    [
+        np.arange(1, 10000, dtype=np.float32),
+        [
+            pd.Series([1, 2, 3], dtype="int32"),
+            pandas.Series([4, 5, 6], dtype="int64"),
+            np.array([7, 8, 9], dtype=np.float32),
+        ],
+        pandas.Categorical([1, 2, 3, 4, 5]),
+    ],
+)
+def test_constructor_dtypes(data):
+    modin_df, pandas_df = create_test_dfs(data)
+    df_equals(modin_df, pandas_df)
+
+
+def test_constructor_columns_and_index():
+    modin_df = pd.DataFrame(
+        [[1, 1, 10], [2, 4, 20], [3, 7, 30]],
+        index=[1, 2, 3],
+        columns=["id", "max_speed", "health"],
+    )
+    pandas_df = pandas.DataFrame(
+        [[1, 1, 10], [2, 4, 20], [3, 7, 30]],
+        index=[1, 2, 3],
+        columns=["id", "max_speed", "health"],
+    )
+    df_equals(modin_df, pandas_df)
+    df_equals(pd.DataFrame(modin_df), pandas.DataFrame(pandas_df))
+    df_equals(
+        pd.DataFrame(modin_df, columns=["max_speed", "health"]),
+        pandas.DataFrame(pandas_df, columns=["max_speed", "health"]),
+    )
+    df_equals(
+        pd.DataFrame(modin_df, index=[1, 2]),
+        pandas.DataFrame(pandas_df, index=[1, 2]),
+    )
+    df_equals(
+        pd.DataFrame(modin_df, index=[1, 2], columns=["health"]),
+        pandas.DataFrame(pandas_df, index=[1, 2], columns=["health"]),
+    )
+    df_equals(
+        pd.DataFrame(modin_df.iloc[:, 0], index=[1, 2, 3]),
+        pandas.DataFrame(pandas_df.iloc[:, 0], index=[1, 2, 3]),
+    )
+    df_equals(
+        pd.DataFrame(modin_df.iloc[:, 0], columns=["NO_EXIST"]),
+        pandas.DataFrame(pandas_df.iloc[:, 0], columns=["NO_EXIST"]),
+    )
+    with pytest.raises(NotImplementedError):
+        pd.DataFrame(modin_df, index=[1, 2, 99999])
+    with pytest.raises(NotImplementedError):
+        pd.DataFrame(modin_df, columns=["NO_EXIST"])
+
+
+def test_constructor_from_index():
+    data = pd.Index([1, 2, 3], name="pricing_date")
+    modin_df, pandas_df = create_test_dfs(data)
+    df_equals(modin_df, pandas_df)