timeseries_scripts/imputation.py
def choose_fill_method(
        message, col, col_name, nan_regs, df, marker_col, one_period):
    '''
    Choose the appropriate function for filling a region of missing values.

    Parameters
    ----------  
    col : pandas.DataFrame
        A column from frame as a separate DataFrame 
    col_name : tuple
        tuple of header levels of column to inspect
    nan_regs : pandas.DataFrame
        DataFrame with each row representing a region of missing data in col
    df : pandas.DataFrame
        DataFrame to patch with n rows
    marker_col : pandas.DataFrame
        An n*1 DataFrame specifying for each row which of the previously treated 
        columns have been patched
    one_period : pandas.Timedelta
        Time resolution of frame and col (15/30/60 minutes)

    Returns
    ----------  
    col : pandas.DataFrame
        An n*1 DataFrame containing col with nan_regs filled
        and another column for the marker
    marker_col: pandas.DataFrame
        Definition as under Parameters, but now appended with markers for col 

    '''
    for i, nan_region in nan_regs.iterrows():
        j = 0
        # Interpolate missing value spans up to 2 hours
        if nan_region['span'] <= timedelta(hours=2):
            col, marker_col = my_interpolate(
                i, j, nan_region, col, col_name, marker_col, nan_regs,
                one_period, message)
        # Guess missing value spans longer than one hour based on other tsos
        # (Only for German wind and solar generation data)
        elif col_name[1][:2] == 'DE' and col_name[2] == 'generation':
            j += 1

            # NOT IMPLEMENTED
            # col = impute(nan_region, col, col_name, nan_regs, df, one_period)

    return col, marker_col

    Choose the appropriate function for filling a region of missing values.

    Parameters
    ----------  
    col : pandas.DataFrame
        A column from frame as a separate DataFrame 
    col_name : tuple
        tuple of header levels of column to inspect
    nan_regs : pandas.DataFrame
        DataFrame with each row representing a region of missing data in col
    df : pandas.DataFrame
        DataFrame to patch with n rows
    marker_col : pandas.DataFrame
        An n*1 DataFrame specifying for each row which of the previously treated 
        columns have been patched
    one_period : pandas.Timedelta
        Time resolution of frame and col (15/30/60 minutes)

    Returns
    ----------  
    col : pandas.DataFrame
        An n*1 DataFrame containing col with nan_regs filled
        and another column for the marker
    marker_col: pandas.DataFrame
        Definition as under Parameters, but now appended with markers for col 

    
Choose the appropriate function for filling a region of missing values.
Choose the appropriate function for filling a region of missing values .
def choose_fill_method(
        message, col, col_name, nan_regs, df, marker_col, one_period):
    for i, nan_region in nan_regs.iterrows():
        j = 0
        if nan_region['span'] <= timedelta(hours=2):
            col, marker_col = my_interpolate(
                i, j, nan_region, col, col_name, marker_col, nan_regs,
                one_period, message)
        elif col_name[1][:2] == 'DE' and col_name[2] == 'generation':
            j += 1
    return col, marker_col
def choose_fill_method ( message , col , col_name , nan_regs , df , marker_col , one_period ) : for i , nan_region in nan_regs . iterrows ( ) : j = 0 if nan_region [ 'span' ] <= timedelta ( hours = 2 ) : col , marker_col = my_interpolate ( i , j , nan_region , col , col_name , marker_col , nan_regs , one_period , message ) elif col_name [ 1 ] [ : 2 ] == 'DE' and col_name [ 2 ] == 'generation' : j += 1 return col , marker_col
Choose the appropriate function for filling a region of missing values.
Choose the appropriate function for filling a region of missing values .
'''
    Choose the appropriate function for filling a region of missing values.

    Parameters
    ----------  
    col : pandas.DataFrame
        A column from frame as a separate DataFrame 
    col_name : tuple
        tuple of header levels of column to inspect
    nan_regs : pandas.DataFrame
        DataFrame with each row representing a region of missing data in col
    df : pandas.DataFrame
        DataFrame to patch with n rows
    marker_col : pandas.DataFrame
        An n*1 DataFrame specifying for each row which of the previously treated 
        columns have been patched
    one_period : pandas.Timedelta
        Time resolution of frame and col (15/30/60 minutes)

    Returns
    ----------  
    col : pandas.DataFrame
        An n*1 DataFrame containing col with nan_regs filled
        and another column for the marker
    marker_col: pandas.DataFrame
        Definition as under Parameters, but now appended with markers for col 

    ''' # Interpolate missing value spans up to 2 hours # Guess missing value spans longer than one hour based on other tsos # (Only for German wind and solar generation data) # NOT IMPLEMENTED # col = impute(nan_region, col, col_name, nan_regs, df, one_period)
message
col
An n*1 DataFrame containing col with nan_regs filled
and another column for the marker
An n * 1 DataFrame containing col with nan_regs filled and another column for the marker
col_name
tuple of header levels of column to inspect
tuple of header levels of column to inspect
nan_regs
DataFrame with each row representing a region of missing data in col
DataFrame with each row representing a region of missing data in col
df
DataFrame to patch with n rows
DataFrame to patch with n rows
marker_col
Definition as under Parameters, but now appended with markers for col
Definition as under Parameters but now appended with markers for col
one_period
Time resolution of frame and col (15/30/60 minutes)
Time resolution of frame and col ( 15 / 30 / 60 minutes )
Returns
None
----------  
None