@@ -676,8 +676,11 @@ def merge_asof(
676676 """
677677 Perform a merge by key distance.
678678
679- This is similar to a left-join except that we match on nearest
680- key rather than equal keys. Both DataFrames must be sorted by the key.
679+ This is similar to a left-join except that we match on nearest
680+ key rather than equal keys. Both DataFrames must be first sorted by
681+ the merge key in ascending order before calling this function.
682+ Sorting by any additional 'by' grouping columns is not required.
683+
681684
682685 For each row in the left DataFrame:
683686
@@ -700,19 +703,22 @@ def merge_asof(
700703 Second pandas object to merge.
701704 on : label
702705 Field name to join on. Must be found in both DataFrames.
703- The data MUST be ordered . Furthermore this must be a numeric column,
704- such as datetimelike, integer, or float. On or left_on/right_on
705- must be given.
706+ The data MUST be in ascending order . Furthermore this must be
707+ a numeric column, such as datetimelike, integer, or float. 'on'
708+ or 'left_on' / 'right_on' must be given.
706709 left_on : label
707- Field name to join on in left DataFrame.
710+ Field name to join on in left DataFrame. If specified, sort the left
711+ DataFrame by this column in ascending order before merging.
708712 right_on : label
709- Field name to join on in right DataFrame.
713+ Field name to join on in right DataFrame. If specified, sort the right
714+ DataFrame by this column in ascending order before merging.
710715 left_index : bool
711716 Use the index of the left DataFrame as the join key.
712717 right_index : bool
713718 Use the index of the right DataFrame as the join key.
714719 by : column name or list of column names
715- Match on these columns before performing merge operation.
720+ Match on these columns before performing merge operation. It is not required
721+ to sort by these columns.
716722 left_by : column name
717723 Field names to match on in the left DataFrame.
718724 right_by : column name
@@ -736,7 +742,9 @@ def merge_asof(
736742 Returns
737743 -------
738744 DataFrame
739- A DataFrame of the two merged objects.
745+ A DataFrame of the two merged objects, containing all rows from the
746+ left DataFrame and the nearest matches from the right DataFrame.
747+
740748
741749 See Also
742750 --------
0 commit comments