@@ -506,8 +506,8 @@ You can also pass a list of dicts or Series:
506
506
507
507
.. _merging.join :
508
508
509
- Database-style DataFrame joining/merging
510
- ----------------------------------------
509
+ Database-style DataFrame or named Series joining/merging
510
+ --------------------------------------------------------
511
511
512
512
pandas has full-featured, **high performance ** in-memory join operations
513
513
idiomatically very similar to relational databases like SQL. These methods
@@ -522,7 +522,7 @@ Users who are familiar with SQL but new to pandas might be interested in a
522
522
:ref: `comparison with SQL<compare_with_sql.join> `.
523
523
524
524
pandas provides a single function, :func: `~pandas.merge `, as the entry point for
525
- all standard database join operations between ``DataFrame `` objects:
525
+ all standard database join operations between ``DataFrame `` or named `` Series `` objects:
526
526
527
527
::
528
528
@@ -531,40 +531,40 @@ all standard database join operations between ``DataFrame`` objects:
531
531
suffixes=('_x', '_y'), copy=True, indicator=False,
532
532
validate=None)
533
533
534
- * ``left ``: A DataFrame object.
535
- * ``right ``: Another DataFrame object.
534
+ * ``left ``: A DataFrame or named Series object.
535
+ * ``right ``: Another DataFrame or named Series object.
536
536
* ``on ``: Column or index level names to join on. Must be found in both the left
537
- and right DataFrame objects. If not passed and ``left_index `` and
537
+ and right DataFrame and/or Series objects. If not passed and ``left_index `` and
538
538
``right_index `` are ``False ``, the intersection of the columns in the
539
- DataFrames will be inferred to be the join keys.
540
- * ``left_on ``: Columns or index levels from the left DataFrame to use as
539
+ DataFrames and/or Series will be inferred to be the join keys.
540
+ * ``left_on ``: Columns or index levels from the left DataFrame or Series to use as
541
541
keys. Can either be column names, index level names, or arrays with length
542
- equal to the length of the DataFrame.
543
- * ``right_on ``: Columns or index levels from the right DataFrame to use as
542
+ equal to the length of the DataFrame or Series .
543
+ * ``right_on ``: Columns or index levels from the right DataFrame or Series to use as
544
544
keys. Can either be column names, index level names, or arrays with length
545
- equal to the length of the DataFrame.
545
+ equal to the length of the DataFrame or Series .
546
546
* ``left_index ``: If ``True ``, use the index (row labels) from the left
547
- DataFrame as its join key(s). In the case of a DataFrame with a MultiIndex
547
+ DataFrame or Series as its join key(s). In the case of a DataFrame or Series with a MultiIndex
548
548
(hierarchical), the number of levels must match the number of join keys
549
- from the right DataFrame.
550
- * ``right_index ``: Same usage as ``left_index `` for the right DataFrame
549
+ from the right DataFrame or Series .
550
+ * ``right_index ``: Same usage as ``left_index `` for the right DataFrame or Series
551
551
* ``how ``: One of ``'left' ``, ``'right' ``, ``'outer' ``, ``'inner' ``. Defaults
552
552
to ``inner ``. See below for more detailed description of each method.
553
553
* ``sort ``: Sort the result DataFrame by the join keys in lexicographical
554
554
order. Defaults to ``True ``, setting to ``False `` will improve performance
555
555
substantially in many cases.
556
556
* ``suffixes ``: A tuple of string suffixes to apply to overlapping
557
557
columns. Defaults to ``('_x', '_y') ``.
558
- * ``copy ``: Always copy data (default ``True ``) from the passed DataFrame
558
+ * ``copy ``: Always copy data (default ``True ``) from the passed DataFrame or named Series
559
559
objects, even when reindexing is not necessary. Cannot be avoided in many
560
560
cases but may improve performance / memory usage. The cases where copying
561
561
can be avoided are somewhat pathological but this option is provided
562
562
nonetheless.
563
563
* ``indicator ``: Add a column to the output DataFrame called ``_merge ``
564
564
with information on the source of each row. ``_merge `` is Categorical-type
565
565
and takes on a value of ``left_only `` for observations whose merge key
566
- only appears in ``'left' `` DataFrame, ``right_only `` for observations whose
567
- merge key only appears in ``'right' `` DataFrame, and ``both `` if the
566
+ only appears in ``'left' `` DataFrame or Series , ``right_only `` for observations whose
567
+ merge key only appears in ``'right' `` DataFrame or Series , and ``both `` if the
568
568
observation's merge key is found in both.
569
569
570
570
* ``validate `` : string, default None.
@@ -584,10 +584,10 @@ all standard database join operations between ``DataFrame`` objects:
584
584
585
585
Support for specifying index levels as the ``on ``, ``left_on ``, and
586
586
``right_on `` parameters was added in version 0.23.0.
587
+ Support for merging named ``Series `` objects was added in version 0.24.0.
587
588
588
- The return type will be the same as ``left ``. If ``left `` is a ``DataFrame ``
589
- and ``right `` is a subclass of DataFrame, the return type will still be
590
- ``DataFrame ``.
589
+ The return type will be the same as ``left ``. If ``left `` is a ``DataFrame `` or named ``Series ``
590
+ and ``right `` is a subclass of ``DataFrame ``, the return type will still be ``DataFrame ``.
591
591
592
592
``merge `` is a function in the pandas namespace, and it is also available as a
593
593
``DataFrame `` instance method :meth: `~DataFrame.merge `, with the calling
0 commit comments