w3resource

Pandas: Data Manipulation - merge_ordered() function

merge_ordered() function

Perform merge with optional filling/interpolation designed for ordered data like time series data. Optionally perform group-wise merge.

Syntax:

pandas.merge_ordered(left, right, on=None, left_on=None, right_on=None, left_by=None, right_by=None, fill_method=None, suffixes=('_x', '_y'), how='outer')

Parameters:

Name Description Type Default Value Required / Optional
left DataFrame   Required
right DataFrame   Required
on Field names to join on. Must be found in both DataFrames. label or list   Required
left_on Field names to join on in left DataFrame. Can be a vector or list of vectors of the length of the DataFrame to use a particular vector as the join key instead of columns. label or list, or array-like Optional
right_on Field names to join on in right DataFrame or vector/list of vectors per left_on docs label or list, or array-like Optional
left_by Group left DataFrame by group columns and merge piece by piece with right DataFrame column name or list of column names Optional
right_by Group right DataFrame by group columns and merge piece by piece with left DataFrame. column name or list of column names Optional
fill_method Interpolation method for data. {‘ffill’, None} Default: None Optional
suffixes A length-2 sequence where each element is optionally a string indicating the suffix to add to overlapping column names in left and right respectively. Pass a value of None instead of a string to indicate that the column name from left or right should be left as-is, with no suffix. At least one of the values must not be None. Sequence Default: (“_x”, “_y”) Optional
how
  • left: use only keys from left frame (SQL: left outer join)
  • right: use only keys from right frame (SQL: right outer join)
  • outer: use union of keys from both frames (SQL: full outer join)
  • inner: use intersection of keys from both frames (SQL: inner join)
{‘left’, ‘right’, ‘outer’, ‘inner’}, Default: ‘outer’ Optional

Returns: merged: The output type will the be same as ‘left’, if it is a subclass of DataFrame.

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: merge() function
Next: merge_asof() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/merge_ordered.php