acidplyr.right_join

acidplyr.right_join(x: DataFrame, y: DataFrame, by: str | list[str]) DataFrame

Right join: equivalent to left_join(y, x, by).

Parameters:
  • x (pd.DataFrame) – Left DataFrame.

  • y (pd.DataFrame) – Right DataFrame; every row is kept.

  • by (str or list of str) – Column name(s) to join on. Must exist in both x and y with matching dtypes.

Returns:

All rows from y, with matching columns from x where available (NaN otherwise).

Return type:

pd.DataFrame

Examples

>>> import pandas as pd
>>> x = pd.DataFrame(
...     {
...         "name": ["Mick", "John", "Paul"],
...         "band": ["Stones", "Beatles", "Beatles"],
...     }
... )
>>> y = pd.DataFrame({"name": ["John", "Paul", "Keith"]})
>>> right_join(x, y, by="name")["name"].tolist()
['John', 'Paul', 'Keith']