pandas.
merge_ordered
Perform merge with optional filling/interpolation.
Designed for ordered data like time series data. Optionally perform group-wise merge (see examples).
Field names to join on. Must be found in both DataFrames.
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.
Field names to join on in right DataFrame or vector/list of vectors per left_on docs.
Group left DataFrame by group columns and merge piece by piece with right DataFrame.
Group right DataFrame by group columns and merge piece by piece with left DataFrame.
Interpolation method for data.
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.
Changed in version 0.25.0.
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).
The merged DataFrame output type will the be same as ‘left’, if it is a subclass of DataFrame.
See also
merge
merge_asof
Examples
>>> A key lvalue group 0 a 1 a 1 c 2 a 2 e 3 a 3 a 1 b 4 c 2 b 5 e 3 b
>>> B Key rvalue 0 b 1 1 c 2 2 d 3
>>> merge_ordered(A, B, fill_method='ffill', left_by='group') group key lvalue rvalue 0 a a 1 NaN 1 a b 1 1.0 2 a c 2 2.0 3 a d 2 3.0 4 a e 3 3.0 5 b a 1 NaN 6 b b 1 1.0 7 b c 2 2.0 8 b d 2 3.0 9 b e 3 3.0