Repository: modin-project/modin

Issue:
'setitem' raise internal error if setting the first column and indices isn't aligned
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Any
- **Modin version** (`modin.__version__`): e74e01279b8c1b6d01652e2e24a060e3ee47b919 
- **Python version**: Any
- **Code we can use to reproduce**:
```python
import modin.pandas as pd

df = pd.DataFrame({"a": [1, 2, 3], "b": [3, 4, 5]})

# Series index isn't equals to the frame's index
sr = pd.Series([10, 20, 30], index=[2, 1, 0])

# Setting the **first** column
df["a"] = sr
print(df) # Internal error

```

<details><summary>Traceback</summary>

```
Traceback (most recent call last):
  File "../rofl.py", line 10, in <module>
    print(df) # Internal error
  File "/localdisk/dchigare/repos/modin_bp/modin/pandas/base.py", line 2741, in __str__
    return repr(self)
  File "/localdisk/dchigare/repos/modin_bp/modin/pandas/dataframe.py", line 184, in __repr__
    result = repr(self._build_repr_df(num_rows, num_cols))
  File "/localdisk/dchigare/repos/modin_bp/modin/pandas/base.py", line 168, in _build_repr_df
    return self.iloc[indexer]._query_compiler.to_pandas()
  File "/localdisk/dchigare/repos/modin_bp/modin/backends/pandas/query_compiler.py", line 205, in to_pandas
    return self._modin_frame.to_pandas()
  File "/localdisk/dchigare/repos/modin_bp/modin/engines/base/frame/data.py", line 2098, in to_pandas
    f"Internal and external indices on axis {axis} do not match.",
  File "/localdisk/dchigare/repos/modin_bp/modin/error_message.py", line 63, in catch_bugs_and_request_email
    " caused this error.\n{}".format(extra_log)
Exception: Internal Error. Please email bug_reports@modin.org with the traceback and command that caused this error.
Internal and external indices on axis 1 do not match.
```

</details>

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
The problem key is in the typo in this line, it should be `other_frames` instead of `other`:
https://github.com/modin-project/modin/blob/e74e01279b8c1b6d01652e2e24a060e3ee47b919/modin/engines/base/frame/data.py#L1822



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
@@ -1810,7 +1810,7 @@ def get_axis_lengths(partitions, axis):
                 or others_lengths[i] != base_lengths
             )
 
-        # perform repartitioning and reindexing for `other` frames if needed
+        # perform repartitioning and reindexing for `other_frames` if needed
         reindexed_other_list = [None] * len(other_frames)
         for i in range(len(other_frames)):
             if do_repartition_others[i]:
@@ -1819,7 +1819,7 @@ def get_axis_lengths(partitions, axis):
                     i
                 ]._frame_mgr_cls.map_axis_partitions(
                     axis,
-                    other[i]._partitions,
+                    other_frames[i]._partitions,
                     make_reindexer(do_repartition_others[i], base_frame_idx + 1 + i),
                     lengths=base_lengths,
                 )


Test patch:
diff --git a/modin/pandas/test/dataframe/test_indexing.py b/modin/pandas/test/dataframe/test_indexing.py
--- a/modin/pandas/test/dataframe/test_indexing.py
+++ b/modin/pandas/test/dataframe/test_indexing.py
@@ -1243,6 +1243,8 @@ def test___setitem__(data):
 
     df_equals(modin_df, pandas_df)
 
+
+def test___setitem__partitions_aligning():
     # from issue #2390
     modin_df = pd.DataFrame({"a": [1, 2, 3]})
     pandas_df = pandas.DataFrame({"a": [1, 2, 3]})
@@ -1259,12 +1261,15 @@ def test___setitem__(data):
     # Setting new column
     pd_df["b"] = pandas.Series(np.arange(4))
     md_df["b"] = pd.Series(np.arange(4))
-
     df_equals(md_df, pd_df)
+
     # Setting existing column
     pd_df["b"] = pandas.Series(np.arange(4))
     md_df["b"] = pd.Series(np.arange(4))
+    df_equals(md_df, pd_df)
 
+    pd_df["a"] = pandas.Series(np.arange(4))
+    md_df["a"] = pd.Series(np.arange(4))
     df_equals(md_df, pd_df)