Skip to content

Commit

Permalink
FIX-#6602: refactor join to avoid distributing a dict object warn…
Browse files Browse the repository at this point in the history
…ing (#6612)

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Sep 29, 2023
1 parent 47b7cae commit 02b1323
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ def join(
if isinstance(other, Series):
if other.name is None:
raise ValueError("Other Series must have a name")
other = self.__constructor__({other.name: other})
other = self.__constructor__(other)
if on is not None:
return self.__constructor__(
query_compiler=self._query_compiler.join(
Expand Down
22 changes: 22 additions & 0 deletions modin/pandas/test/dataframe/test_join_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

import warnings

import matplotlib
import numpy as np
import pandas
Expand Down Expand Up @@ -180,6 +182,26 @@ def test_join_5203():
dfs[0].join([dfs[1], dfs[2]], how="inner", on="a")


def test_join_6602():
abbreviations = pd.Series(
["Major League Baseball", "National Basketball Association"],
index=["MLB", "NBA"],
)
teams = pd.DataFrame(
{
"name": ["Mariners", "Lakers"] * 50,
"league_abbreviation": ["MLB", "NBA"] * 50,
}
)

with warnings.catch_warnings():
# check that join doesn't show UserWarning
warnings.filterwarnings(
"error", "Distributing <class 'dict'> object", category=UserWarning
)
teams.set_index("league_abbreviation").join(abbreviations.rename("league_name"))


@pytest.mark.parametrize(
"test_data, test_data2",
[
Expand Down

0 comments on commit 02b1323

Please sign in to comment.