Repository: modin-project/modin

Issue:
DataFrame.astype(int) has no effect
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:

Ubuntu 20.04

- **Modin version** (`modin.__version__`):

0.7.3+166.g00f57f1.dirty

- **Python version**:

Python 3.8.2

- **Code we can use to reproduce**:

```python
import modin.pandas as pd

df = pd.DataFrame(index=["row1", "row2", "row3"], columns=["col1"])
df.loc["row1"]["col1"] = 11
df.loc["row2"]["col1"] = 21
df.loc["row3"]["col1"] = 31
print(df)
print(df.dtypes)
df1 = df.astype(int)
print(df1)
print(df1.dtypes)
```

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

When DataFrame is first created without any contents, all of its columns are marked as `object` type. Even when it is filled with integers it doesn't change anything. But when `astype(int)` is called, column types should change to `int`. This happens on Pandas but doesn't happen on Modin.

### 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. -->

DataFrame.astype(int) has no effect
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:

Ubuntu 20.04

- **Modin version** (`modin.__version__`):

0.7.3+166.g00f57f1.dirty

- **Python version**:

Python 3.8.2

- **Code we can use to reproduce**:

```python
import modin.pandas as pd

df = pd.DataFrame(index=["row1", "row2", "row3"], columns=["col1"])
df.loc["row1"]["col1"] = 11
df.loc["row2"]["col1"] = 21
df.loc["row3"]["col1"] = 31
print(df)
print(df.dtypes)
df1 = df.astype(int)
print(df1)
print(df1.dtypes)
```

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

When DataFrame is first created without any contents, all of its columns are marked as `object` type. Even when it is filled with integers it doesn't change anything. But when `astype(int)` is called, column types should change to `int`. This happens on Pandas but doesn't happen on Modin.

### 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:

Resolving patch:
diff --git a/modin/engines/base/frame/data.py b/modin/engines/base/frame/data.py
--- a/modin/engines/base/frame/data.py
+++ b/modin/engines/base/frame/data.py
@@ -553,6 +553,8 @@ def astype(self, col_dtypes):
                 elif isinstance(new_dtype, str) and new_dtype == "category":
                     new_dtypes = None
                     break
+                else:
+                    new_dtypes[column] = new_dtype
 
         def astype_builder(df):
             return df.astype({k: v for k, v in col_dtypes.items() if k in df})


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
@@ -809,6 +809,14 @@ def test_astype(self):
         expected_df_casted = expected_df.astype(bad_dtype_dict)
         df_equals(modin_df_casted, expected_df_casted)
 
+        modin_df = pd.DataFrame(index=["row1"], columns=["col1"])
+        modin_df["col1"]["row1"] = 11
+        modin_df_casted = modin_df.astype(int)
+        expected_df = pandas.DataFrame(index=["row1"], columns=["col1"])
+        expected_df["col1"]["row1"] = 11
+        expected_df_casted = expected_df.astype(int)
+        df_equals(modin_df_casted, expected_df_casted)
+
         with pytest.raises(KeyError):
             modin_df.astype({"not_exists": np.uint8})