Skip to content

Commit 4e1f51c

Browse files
authored
DOC: Add cross merge to userguide section (#43801)
1 parent 6847810 commit 4e1f51c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

doc/source/user_guide/merging.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ all standard database join operations between ``DataFrame`` or named ``Series``
562562
(hierarchical), the number of levels must match the number of join keys
563563
from the right DataFrame or Series.
564564
* ``right_index``: Same usage as ``left_index`` for the right DataFrame or Series
565-
* ``how``: One of ``'left'``, ``'right'``, ``'outer'``, ``'inner'``. Defaults
565+
* ``how``: One of ``'left'``, ``'right'``, ``'outer'``, ``'inner'``, ``'cross'``. Defaults
566566
to ``inner``. See below for more detailed description of each method.
567567
* ``sort``: Sort the result DataFrame by the join keys in lexicographical
568568
order. Defaults to ``True``, setting to ``False`` will improve performance
@@ -707,6 +707,7 @@ either the left or right tables, the values in the joined table will be
707707
``right``, ``RIGHT OUTER JOIN``, Use keys from right frame only
708708
``outer``, ``FULL OUTER JOIN``, Use union of keys from both frames
709709
``inner``, ``INNER JOIN``, Use intersection of keys from both frames
710+
``cross``, ``CROSS JOIN``, Create the cartesian product of rows of both frames
710711

711712
.. ipython:: python
712713
@@ -751,6 +752,17 @@ either the left or right tables, the values in the joined table will be
751752
p.plot([left, right], result, labels=["left", "right"], vertical=False);
752753
plt.close("all");
753754
755+
.. ipython:: python
756+
757+
result = pd.merge(left, right, how="cross")
758+
759+
.. ipython:: python
760+
:suppress:
761+
762+
@savefig merging_merge_cross.png
763+
p.plot([left, right], result, labels=["left", "right"], vertical=False);
764+
plt.close("all");
765+
754766
You can merge a mult-indexed Series and a DataFrame, if the names of
755767
the MultiIndex correspond to the columns from the DataFrame. Transform
756768
the Series to a DataFrame using :meth:`Series.reset_index` before merging,

0 commit comments

Comments
 (0)