Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DOC: Incorrect explanation of merge_asof with direction="backward" #53279

Copy link
Copy link
Open
@mosew

Description

@mosew
Issue body actions

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.merge_asof.html

Documentation problem

For each row in the left DataFrame:
        A “backward” search selects the last row in the right DataFrame whose ‘on’ key is less than or equal to the left’s key.

This is incorrect, as evidenced here:

left = pd.DataFrame(
    {
        "id": ["a"],
        "date": pd.to_datetime(
            ["20080102"]
        ),
    },
)

right = pd.DataFrame(
    {
        "id": ["a"],
        "date": pd.to_datetime([
            "20080101",
        ])
    },
)

pd.merge_asof(left=left, right=right, by="id", on="date")
  id date
  a 2008-01-02

Suggested fix for documentation

For each row in the left DataFrame:
        A “backward” search selects the last row in the **left** DataFrame whose ‘on’ key is less than or equal to the left’s key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.