Repository: modin-project/modin

Issue:
read_csv parse mixed float and int column
Modin version: 0.7.4
pandas version compared to: 1.0.3

When reading csv with columns which are both ints and floats, I get a doubling of headers:

minimal.csv (from https://github.com/aalto-trafficsense/public-transport-dataset/blob/master/csv/device_data.csv)
```
"time","device_id","lat","lng","accuracy","activity_1","activity_1_conf","activity_2","activity_2_conf","activity_3","activity_3_conf"
"2016-08-26 09:00:00.206",2,60.186805,24.821049,33.6080017089844,"STILL",75,"IN_VEHICLE",5,"ON_BICYCLE",5
"2016-08-26 09:00:05.428",5,60.192928,24.767222,5,"WALKING",62,"ON_BICYCLE",29,"RUNNING",6
"2016-08-26 09:00:05.818",1,60.166382,24.700443,3,"WALKING",75,"IN_VEHICLE",5,"ON_BICYCLE",5
"2016-08-26 09:00:15.816",1,60.166254,24.700671,3,"WALKING",75,"IN_VEHICLE",5,"ON_BICYCLE",5
"2016-08-26 09:00:16.413",5,60.193055,24.767427,5,"WALKING",85,"ON_BICYCLE",15,"UNKNOWN",0
"2016-08-26 09:00:20.578",3,60.152996,24.745216,3.90000009536743,"STILL",69,"IN_VEHICLE",31,"UNKNOWN",0
```

Code to reproduce issue:
```
import pandas
import modin.pandas
df_modin = modin.pandas.read_csv('minimal.csv')
print(df_modin.head()) # 5 rows 22 columns
df_pandas = pandas.read_csv('minimal.csv')
print(df_modin.head()) # 5 rows  11 columns
```


Discussion:
Hi @mikael-epigram thanks for posting!

I reproduce the `22 columns` tag you are seeing. This is a display bug, the underlying dataframe and metadata are still correct. You can check this for yourself by trying `len(df.columns)`, it will not be 22 in this case.

Thanks for posting!
Great to have that clarified

Resolving patch:
diff --git a/modin/pandas/base.py b/modin/pandas/base.py
--- a/modin/pandas/base.py
+++ b/modin/pandas/base.py
@@ -64,36 +64,42 @@ def _build_repr_df(self, num_rows, num_cols):
                 index=self.index,
                 columns=self.columns if hasattr(self, "columns") else None,
             )
-        # Add one here so that pandas automatically adds the dots
-        # It turns out to be faster to extract 2 extra rows and columns than to
-        # build the dots ourselves.
-        num_rows_for_head = num_rows // 2 + 1
-        num_rows_for_tail = (
-            num_rows_for_head
-            if len(self.index) > num_rows
-            else len(self.index) - num_rows_for_head
-            if len(self.index) - num_rows_for_head >= 0
-            else None
-        )
-        row_indexer = list(range(len(self.index))[:num_rows_for_head]) + (
-            list(range(len(self.index))[-num_rows_for_tail:])
-            if num_rows_for_tail is not None
-            else []
-        )
-        if hasattr(self, "columns"):
-            num_cols_for_front = num_cols // 2 + 1
-            num_cols_for_back = (
-                num_cols_for_front
-                if len(self.columns) > num_cols
-                else len(self.columns) - num_cols_for_front
-                if len(self.columns) - num_cols_for_front >= 0
+        if len(self.index) <= num_rows:
+            row_indexer = slice(None)
+        else:
+            # Add one here so that pandas automatically adds the dots
+            # It turns out to be faster to extract 2 extra rows and columns than to
+            # build the dots ourselves.
+            num_rows_for_head = num_rows // 2 + 1
+            num_rows_for_tail = (
+                num_rows_for_head
+                if len(self.index) > num_rows
+                else len(self.index) - num_rows_for_head
+                if len(self.index) - num_rows_for_head >= 0
                 else None
             )
-            col_indexer = list(range(len(self.columns))[:num_cols_for_front]) + (
-                list(range(len(self.columns))[-num_cols_for_back:])
-                if num_cols_for_back is not None
+            row_indexer = list(range(len(self.index))[:num_rows_for_head]) + (
+                list(range(len(self.index))[-num_rows_for_tail:])
+                if num_rows_for_tail is not None
                 else []
             )
+        if hasattr(self, "columns"):
+            if len(self.columns) <= num_cols:
+                col_indexer = slice(None)
+            else:
+                num_cols_for_front = num_cols // 2 + 1
+                num_cols_for_back = (
+                    num_cols_for_front
+                    if len(self.columns) > num_cols
+                    else len(self.columns) - num_cols_for_front
+                    if len(self.columns) - num_cols_for_front >= 0
+                    else None
+                )
+                col_indexer = list(range(len(self.columns))[:num_cols_for_front]) + (
+                    list(range(len(self.columns))[-num_cols_for_back:])
+                    if num_cols_for_back is not None
+                    else []
+                )
             indexer = row_indexer, col_indexer
         else:
             indexer = row_indexer


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
@@ -5581,6 +5581,18 @@ def test___repr__(self):
 
         assert repr(pandas_df) == repr(modin_df)
 
+        # From Issue #1705
+        string_data = """"time","device_id","lat","lng","accuracy","activity_1","activity_1_conf","activity_2","activity_2_conf","activity_3","activity_3_conf"
+"2016-08-26 09:00:00.206",2,60.186805,24.821049,33.6080017089844,"STILL",75,"IN_VEHICLE",5,"ON_BICYCLE",5
+"2016-08-26 09:00:05.428",5,60.192928,24.767222,5,"WALKING",62,"ON_BICYCLE",29,"RUNNING",6
+"2016-08-26 09:00:05.818",1,60.166382,24.700443,3,"WALKING",75,"IN_VEHICLE",5,"ON_BICYCLE",5
+"2016-08-26 09:00:15.816",1,60.166254,24.700671,3,"WALKING",75,"IN_VEHICLE",5,"ON_BICYCLE",5
+"2016-08-26 09:00:16.413",5,60.193055,24.767427,5,"WALKING",85,"ON_BICYCLE",15,"UNKNOWN",0
+"2016-08-26 09:00:20.578",3,60.152996,24.745216,3.90000009536743,"STILL",69,"IN_VEHICLE",31,"UNKNOWN",0"""
+        pandas_df = pandas.read_csv(io.StringIO(string_data))
+        modin_df = pd.read_csv(io.StringIO(string_data))
+        assert repr(pandas_df) == repr(modin_df)
+
     @pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
     def test_reset_index_with_multi_index(self, data):
         modin_df = pd.DataFrame(data)