Repository: modin-project/modin

Issue:
2D assignment does not reshape correctly
### Describe the problem
<!-- Describe the problem clearly here. -->
Seems #318 is broken again.

### 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. -->
```python
import modin.pandas as pd
import numpy as np
df = pd.DataFrame({'a': [1,2], 'b':[3,4]})
df.loc[df['a'] > 1, 'b'] = np.log(df['b'])
print(df)
```

raises:
```
Traceback (most recent call last):
  File "c:\foo\modin\pandas\indexing.py", line 407, in _broadcast_item
    return np.broadcast_to(item, to_shape)
  File "<__array_function__ internals>", line 6, in broadcast_to
  File "C:\miniconda3\envs\foo\lib\site-packages\numpy\lib\stride_tricks.py", line 182, in broadcast_to
    return _broadcast_to(array, shape, subok=subok, readonly=True)
  File "C:\miniconda3\envs\foo\lib\site-packages\numpy\lib\stride_tricks.py", line 127, in _broadcast_to
    op_flags=['readonly'], itershape=shape, order='C')
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,) and requested shape (1,1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\foo\modin\pandas\indexing.py", line 609, in __setitem__
    row_lookup, col_lookup, row_scaler, col_scaler
  File "c:\foo\modin\pandas\indexing.py", line 360, in __setitem__
    item = self._broadcast_item(row_lookup, col_lookup, item, to_shape)
  File "c:\foo\modin\pandas\indexing.py", line 412, in _broadcast_item
    "{to_shape}".format(from_shape=from_shape, to_shape=to_shape)
ValueError: could not broadcast input array from shape (2,) into shape (1, 1)
```

Expected output (as Pandas show it):
```
   a         b
0  1  3.000000
1  2  1.386294
```


Discussion:
It happens because we're missing modin Series in this `isinstance` check, so we're not performing reindexing, getting incorrect shape and then getting an error when trying to broadcast:
https://github.com/modin-project/modin/blob/1a8cd0a3765df4cd9f76480e9862f522818333b2/modin/pandas/indexing.py#L387-L392
I've changed this check to the following on top of the #2536 and the reproducer above started to work similar to pandas:
```python
if isinstance(item, (pandas.Series, pandas.DataFrame, Series, DataFrame)):
    ...
```

Resolving patch:
diff --git a/modin/pandas/indexing.py b/modin/pandas/indexing.py
--- a/modin/pandas/indexing.py
+++ b/modin/pandas/indexing.py
@@ -384,7 +384,7 @@ def _broadcast_item(self, row_lookup, col_lookup, item, to_shape):
         """
         # It is valid to pass a DataFrame or Series to __setitem__ that is larger than
         # the target the user is trying to overwrite. This
-        if isinstance(item, (pandas.Series, pandas.DataFrame, DataFrame)):
+        if isinstance(item, (pandas.Series, pandas.DataFrame, Series, DataFrame)):
             if not all(idx in item.index for idx in row_lookup):
                 raise ValueError(
                     "Must have equal len keys and value when setting with "


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
@@ -463,6 +463,15 @@ def test_iloc_nested_assignment(data):
     df_equals(modin_df, pandas_df)
 
 
+def test_loc_series():
+    md_df, pd_df = create_test_dfs({"a": [1, 2], "b": [3, 4]})
+
+    pd_df.loc[pd_df["a"] > 1, "b"] = np.log(pd_df["b"])
+    md_df.loc[md_df["a"] > 1, "b"] = np.log(md_df["b"])
+
+    df_equals(pd_df, md_df)
+
+
 @pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
 def test_pop(request, data):
     modin_df = pd.DataFrame(data)