code: def fill_missing_timestamps(
      df: pd.DataFrame,
      frequency: str,
      first_time_stamp: pd.Timestamp = None,
      last_time_stamp: pd.Timestamp = None,
  ) -> pd.DataFrame:
      """Fills a DataFrame with missing timestamps based on a defined frequency.
  
      If timestamps are missing, this function will re-index the DataFrame.
      If timestamps are not missing, then the function will return the DataFrame
      unmodified.
  
      Examples:
          Functional usage
  
          >>> import pandas as pd
          >>> import janitor.timeseries
          >>> df = janitor.timeseries.fill_missing_timestamps(
          ...     df=pd.DataFrame(...),
          ...     frequency="1H",
          ... )  # doctest: +SKIP
  
          Method chaining example:
  
          >>> import pandas as pd
          >>> import janitor.timeseries
          >>> df = (
          ...     pd.DataFrame(...)
          ...     .fill_missing_timestamps(frequency="1H")
          ... )  # doctest: +SKIP
  
      Args:
          df: DataFrame which needs to be tested for missing timestamps
          frequency: Sampling frequency of the data.
              Acceptable frequency strings are available
              [here](https://pandas.pydata.org/docs/user_guide/timeseries.html#timeseries-offset-aliases).
              Check offset aliases under time series in user guide
          first_time_stamp: Timestamp expected to start from;
              defaults to `None`. If no input is provided, assumes the
              minimum value in `time_series`.
          last_time_stamp: Timestamp expected to end with; defaults to `None`.
              If no input is provided, assumes the maximum value in
              `time_series`.
  
      Returns:
          DataFrame that has a complete set of contiguous datetimes.
      """
      # Check all the inputs are the correct data type
      check("frequency", frequency, [str])
      check(
          "first_time_stamp",
          first_time_stamp,
          [pd.Timestamp, type(None)],
      )
      check(
          "last_time_stamp", last_time_stamp, [pd.Timestamp, type(None)]
      )
  
      if first_time_stamp is None:
          first_time_stamp = df.index.min()
      if last_time_stamp is None:
          last_time_stamp = df.index.max()
  
      # Generate expected timestamps
      expected_timestamps = pd.date_range(
          start=first_time_stamp, end=last_time_stamp, freq=frequency
      )
  
      return df.reindex(expected_timestamps)
  
file_path: pyjanitor/janitor/timeseries.py
imports: import itertools
  from typing import Dict, Union
  import pandas
  import pandas_flavor
  from .errors import JanitorError
  from .utils import check
label_desc: Use image node_id 1 for calling a global function with example usage: fill_missing_timestamps(df, frequency, first_time_stamp, last_time_stamp) and returns: df