code: def 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",
  ):
      """Perform merge with optional filling/interpolation designed for ordered
      data like time series data. Optionally perform group-wise merge (see
      examples)
  
      Parameters
      ----------
      left : DataFrame
      right : DataFrame
      on : label or list
          Field names to join on. Must be found in both DataFrames.
      left_on : label or list, or array-like
          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
      right_on : label or list, or array-like
          Field names to join on in right DataFrame or vector/list of vectors per
          left_on docs
      left_by : column name or list of column names
          Group left DataFrame by group columns and merge piece by piece with
          right DataFrame
      right_by : column name or list of column names
          Group right DataFrame by group columns and merge piece by piece with
          left DataFrame
      fill_method : {'ffill', None}, default None
          Interpolation method for data
      suffixes : 2-length sequence (tuple, list, ...)
          Suffix to apply to overlapping column names in the left and right
          side, respectively
      how : {'left', 'right', 'outer', 'inner'}, default 'outer'
          * 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)
  
          .. versionadded:: 0.19.0
  
      Returns
      -------
      merged : DataFrame
          The output type will the be same as 'left', if it is a subclass
          of DataFrame.
  
      See Also
      --------
      merge
      merge_asof
  
      Examples
      --------
      >>> A                      >>> B
            key  lvalue group        key  rvalue
      0   a       1     a        0     b       1
      1   c       2     a        1     c       2
      2   e       3     a        2     d       3
      3   a       1     b
      4   c       2     b
      5   e       3     b
  
      >>> 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
      """
  
      def _merger(x, y):
          # perform the ordered merge operation
          op = _OrderedMerge(
              x,
              y,
              on=on,
              left_on=left_on,
              right_on=right_on,
              suffixes=suffixes,
              fill_method=fill_method,
              how=how,
          )
          return op.get_result()
  
      if left_by is not None and right_by is not None:
          raise ValueError("Can only group either left or right frames")
      elif left_by is not None:
          result, _ = _groupby_and_merge(
              left_by,
              on,
              left,
              right,
              lambda x, y: _merger(x, y),
              check_duplicates=False,
          )
      elif right_by is not None:
          result, _ = _groupby_and_merge(
              right_by,
              on,
              right,
              left,
              lambda x, y: _merger(y, x),
              check_duplicates=False,
          )
      else:
          result = _merger(left, right)
      return result
  
imports: import copy
  import string
  import warnings
  import numpy
  from pandas._libs import hashtable, join, lib
  import pandas.compat
  from pandas.compat import filter, lzip, map, range, zip
  from pandas.errors import MergeError
  from pandas.util._decorators import Appender, Substitution
  from pandas.core.dtypes.common import ensure_float64, ensure_int64, ensure_object, is_array_like, is_bool, is_bool_dtype, is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype, is_datetimelike, is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_int64_dtype, is_integer, is_integer_dtype, is_list_like, is_number, is_numeric_dtype, is_object_dtype, needs_i8_conversion
  from pandas.core.dtypes.missing import isnull, na_value_for_dtype
  from pandas import Categorical, DataFrame, Index, MultiIndex, Series, Timedelta
  import pandas.core.algorithms
  from pandas.core.arrays.categorical import _recode_for_categories
  import pandas.core.common
  from pandas.core.frame import _merge_doc
  from pandas.core.internals import concatenate_block_managers, items_overlap_with_suffix
  import pandas.core.sorting
  from pandas.core.sorting import is_int64_overflow_possible
label_desc: Use image node_id 3 for calling a global function with example usage: merge_ordered(left, right, on, left_on, right_on, left_by, right_by, fill_method, suffixes, how) and returns: result, op