def step_is_chg_state(step_df, chg):
    """
    Helper function to determine whether a given dataframe corresponding
    to a single cycle_index/step is charging or discharging, only intended
    to be used with a dataframe for single step/cycle

    Args:
         step_df (pandas.DataFrame): dataframe to determine whether
            charging or discharging
         chg (bool): Charge state; True if charging

    Returns:
        (bool): True if step is the charge state specified.
    """
    cap = step_df[["charge_capacity", "discharge_capacity"]]
    cap = cap.diff(axis=0).mean(axis=0).diff().iloc[-1]

    if chg:  # Charging
        return cap < 0
    else:  # Discharging
        return cap > 0