Skip to content

Commit cee481b

Browse files
authored
Fix .loc[] assignment for Modin Series (#2555)
Signed-off-by: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
1 parent bd60284 commit cee481b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

modin/pandas/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def _broadcast_item(self, row_lookup, col_lookup, item, to_shape):
384384
"""
385385
# It is valid to pass a DataFrame or Series to __setitem__ that is larger than
386386
# the target the user is trying to overwrite. This
387-
if isinstance(item, (pandas.Series, pandas.DataFrame, DataFrame)):
387+
if isinstance(item, (pandas.Series, pandas.DataFrame, Series, DataFrame)):
388388
if not all(idx in item.index for idx in row_lookup):
389389
raise ValueError(
390390
"Must have equal len keys and value when setting with "

modin/pandas/test/dataframe/test_indexing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,15 @@ def test_iloc_nested_assignment(data):
463463
df_equals(modin_df, pandas_df)
464464

465465

466+
def test_loc_series():
467+
md_df, pd_df = create_test_dfs({"a": [1, 2], "b": [3, 4]})
468+
469+
pd_df.loc[pd_df["a"] > 1, "b"] = np.log(pd_df["b"])
470+
md_df.loc[md_df["a"] > 1, "b"] = np.log(md_df["b"])
471+
472+
df_equals(pd_df, md_df)
473+
474+
466475
@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
467476
def test_pop(request, data):
468477
modin_df = pd.DataFrame(data)

0 commit comments

Comments
 (0)