Skip to content

Commit

Permalink
Fix .loc[] assignment for Modin Series (#2555)
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
  • Loading branch information
vnlitvinov committed Dec 17, 2020
1 parent bd60284 commit cee481b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modin/pandas/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
9 changes: 9 additions & 0 deletions modin/pandas/test/dataframe/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cee481b

Please sign in to comment.