oplus/weather_data/weather_data.py
def _check_and_sanitize_datetime_instants(df):
    """
    Parameters
    ----------
    df

    Returns
    -------
    sanitized df
    """
    # leave if not relevant
    if df is None or len(df) == 0:
        return df

    # check datetime index
    if not isinstance(df.index, pd.DatetimeIndex):
        raise ValueError("df index must be a datetime index.")

    # force frequency if needed
    if df.index.freq != "H":
        forced_df = df.asfreq("H")
        # check no change
        try:
            assert_index_equal(df.index, forced_df.index)
        except AssertionError:
            raise ValueError(
                f"Couldn't convert to hourly datetime instants. Probable cause : "
                f"given start instant ({df.index[0]}) is incorrect and data can't match because of leap year issues."
            ) from None
        # replace old variable
        df = forced_df

    # check first minute is 0
    if df.index[0].minute != 0:
        raise ValueError("Minutes must be 0.")

    return df
def _check_and_sanitize_datetime_instants(df):
    """
    Parameters
    ----------
    df

    Returns
    -------
    sanitized df
    """
    # leave if not relevant
    if df is None or len(df) == 0:
        return df

    # check datetime index
    if not isinstance(df.index, pd.DatetimeIndex):
        raise ValueError("df index must be a datetime index.")

    # force frequency if needed
    if df.index.freq != "H":
        forced_df = df.asfreq("H")
        # check no change
        try:
            assert_index_equal(df.index, forced_df.index)
        except AssertionError:
            raise ValueError(
                f"Couldn't convert to hourly datetime instants. Probable cause : "
                f"given start instant ({df.index[0]}) is incorrect and data can't match because of leap year issues."
            ) from None
        # replace old variable
        df = forced_df

    # check first minute is 0
    if df.index[0].minute != 0:
        raise ValueError("Minutes must be 0.")

    return df
Parameters
    ----------
    df

    Returns
    -------
    sanitized df