timeseries_scripts/read.py
def read_ceps(filepath, variable_name, url, headers):
    '''Read a file from CEPS into a DataFrame'''
    df = pd.read_excel(
        io=filepath,
        header=2,
        skiprows=None,
        index_col=0,
        parse_cols=[0, 1, 2]
    )

    df.index = pd.to_datetime(df.index.rename('timestamp'))

    df.index = df.index.tz_localize('Europe/Brussels', ambiguous='infer')
    df.index = df.index.tz_convert(None)

    # Translate columns
    colmap = {
        'WPP [MW]': {
            'region': 'CZ',
            'variable': 'wind_onshore',
            'attribute': 'generation',
            'source': 'CEPS',
            'web': url,
            'unit': 'MW'
        },
        'PVPP [MW]': {
            'region': 'CZ',
            'variable': 'solar',
            'attribute': 'generation',
            'source': 'CEPS',
            'web': url,
            'unit': 'MW'
        }
    }

    # Create the MultiIndex
    tuples = [tuple(colmap[col][level] for level in headers)
              for col in df.columns]
    df.columns = pd.MultiIndex.from_tuples(tuples, names=headers)

    return df
Read a file from CEPS into a DataFrame
Read a file from CEPS into a DataFrame
Read a file from CEPS into a DataFrame
def read_ceps(filepath, variable_name, url, headers):
    df = pd.read_excel(
        io=filepath,
        header=2,
        skiprows=None,
        index_col=0,
        parse_cols=[0, 1, 2]
    )
    df.index = pd.to_datetime(df.index.rename('timestamp'))
    df.index = df.index.tz_localize('Europe/Brussels', ambiguous='infer')
    df.index = df.index.tz_convert(None)
    colmap = {
        'WPP [MW]': {
            'region': 'CZ',
            'variable': 'wind_onshore',
            'attribute': 'generation',
            'source': 'CEPS',
            'web': url,
            'unit': 'MW'
        },
        'PVPP [MW]': {
            'region': 'CZ',
            'variable': 'solar',
            'attribute': 'generation',
            'source': 'CEPS',
            'web': url,
            'unit': 'MW'
        }
    }
    tuples = [tuple(colmap[col][level] for level in headers)
              for col in df.columns]
    df.columns = pd.MultiIndex.from_tuples(tuples, names=headers)
    return df
def read_ceps ( filepath , variable_name , url , headers ) : df = pd . read_excel ( io = filepath , header = 2 , skiprows = None , index_col = 0 , parse_cols = [ 0 , 1 , 2 ] ) df . index = pd . to_datetime ( df . index . rename ( 'timestamp' ) ) df . index = df . index . tz_localize ( 'Europe/Brussels' , ambiguous = 'infer' ) df . index = df . index . tz_convert ( None ) colmap = { 'WPP [MW]' : { 'region' : 'CZ' , 'variable' : 'wind_onshore' , 'attribute' : 'generation' , 'source' : 'CEPS' , 'web' : url , 'unit' : 'MW' } , 'PVPP [MW]' : { 'region' : 'CZ' , 'variable' : 'solar' , 'attribute' : 'generation' , 'source' : 'CEPS' , 'web' : url , 'unit' : 'MW' } } tuples = [ tuple ( colmap [ col ] [ level ] for level in headers ) for col in df . columns ] df . columns = pd . MultiIndex . from_tuples ( tuples , names = headers ) return df
Read a file from CEPS into a DataFrame
Read a file from CEPS into a DataFrame
'''Read a file from CEPS into a DataFrame''' # Translate columns # Create the MultiIndex
filepath
variable_name
url
headers