@@ -643,6 +643,7 @@ def join(
643643 left_on : None = None ,
644644 right_on : None = None ,
645645 join_keys : None = None ,
646+ keep_duplicate_keys : bool = False ,
646647 ) -> DataFrame : ...
647648
648649 @overload
@@ -655,6 +656,7 @@ def join(
655656 left_on : str | Sequence [str ],
656657 right_on : str | Sequence [str ],
657658 join_keys : tuple [list [str ], list [str ]] | None = None ,
659+ keep_duplicate_keys : bool = False ,
658660 ) -> DataFrame : ...
659661
660662 @overload
@@ -667,6 +669,7 @@ def join(
667669 join_keys : tuple [list [str ], list [str ]],
668670 left_on : None = None ,
669671 right_on : None = None ,
672+ keep_duplicate_keys : bool = False ,
670673 ) -> DataFrame : ...
671674
672675 def join (
@@ -678,6 +681,7 @@ def join(
678681 left_on : str | Sequence [str ] | None = None ,
679682 right_on : str | Sequence [str ] | None = None ,
680683 join_keys : tuple [list [str ], list [str ]] | None = None ,
684+ keep_duplicate_keys : bool = False ,
681685 ) -> DataFrame :
682686 """Join this :py:class:`DataFrame` with another :py:class:`DataFrame`.
683687
@@ -690,11 +694,23 @@ def join(
690694 "right", "full", "semi", "anti".
691695 left_on: Join column of the left dataframe.
692696 right_on: Join column of the right dataframe.
697+ keep_duplicate_keys: When False, the columns from the right DataFrame
698+ that have identical names in the ``on`` fields to the left DataFrame
699+ will be dropped.
693700 join_keys: Tuple of two lists of column names to join on. [Deprecated]
694701
695702 Returns:
696703 DataFrame after join.
697704 """
705+ if join_keys is not None :
706+ warnings .warn (
707+ "`join_keys` is deprecated, use `on` or `left_on` with `right_on`" ,
708+ category = DeprecationWarning ,
709+ stacklevel = 2 ,
710+ )
711+ left_on = join_keys [0 ]
712+ right_on = join_keys [1 ]
713+
698714 # This check is to prevent breaking API changes where users prior to
699715 # DF 43.0.0 would pass the join_keys as a positional argument instead
700716 # of a keyword argument.
@@ -705,18 +721,10 @@ def join(
705721 and isinstance (on [1 ], list )
706722 ):
707723 # We know this is safe because we've checked the types
708- join_keys = on # type: ignore[assignment]
724+ left_on = on [0 ]
725+ right_on = on [1 ]
709726 on = None
710727
711- if join_keys is not None :
712- warnings .warn (
713- "`join_keys` is deprecated, use `on` or `left_on` with `right_on`" ,
714- category = DeprecationWarning ,
715- stacklevel = 2 ,
716- )
717- left_on = join_keys [0 ]
718- right_on = join_keys [1 ]
719-
720728 if on is not None :
721729 if left_on is not None or right_on is not None :
722730 error_msg = "`left_on` or `right_on` should not provided with `on`"
@@ -735,7 +743,9 @@ def join(
735743 if isinstance (right_on , str ):
736744 right_on = [right_on ]
737745
738- return DataFrame (self .df .join (right .df , how , left_on , right_on ))
746+ return DataFrame (
747+ self .df .join (right .df , how , left_on , right_on , keep_duplicate_keys )
748+ )
739749
740750 def join_on (
741751 self ,
0 commit comments