annular.tariffs

Attributes

T

Classes

TariffManager

A manager object for energy network tariffs.

Functions

filter_dataframe(→ pandas.Series | numbers.Real)

Filter a dataframe by multiple columns.

parse_weekday_weekend(→ str)

Parse the weekday weekend from a date.

is_dutch_holiday(→ bool)

Check if date is a Dutch holiday, if not already a weekend by definition.

Module Contents

annular.tariffs.T[source]
class annular.tariffs.TariffManager(tariff_data: dict[str, pandas.Series])[source]

A manager object for energy network tariffs.

Includes support for intelligently parsing timestamps to various time-based indexing options. Tariffs are retrievable by (case-insensitive) name through various fetch_* methods.

Parameters:

tariff_data – Dictionary where keys are tariff names and values are series of tariff values and indices.

data[source]
classmethod from_folder(path: pathlib.Path, preselect: collections.abc.Mapping[str, str | numbers.Real]) T[source]

Create a TariffManager from csv files in a folder.

Parameters:
  • path – Path to the folder with tariff data in csv format.

  • preselect – Dictionary specifying the category within the tariff. Any tariff may be indexed both categorically and temporally. This preselect argument should at least specify a value for each categorical index, i.e., column in the tariff file. E.g.: {“grid level”: “distribution”, “consumer type”: “small”}. If any of the categories given to preselect are not present in the tariff data, they are silently ignored.

fetch_value(name: str) numbers.Real[source]

Fetch a single-valued tariff.

Parameters:

name – Name of the tariff.

Returns:

Value for a specific tariff.

fetch_timeseries(name: str, timestamps: pandas.DatetimeIndex) pandas.Series[source]

Fetch tariff value for each given timestamp.

Parameters:
  • name – Name of the tariff.

  • timestamps – Datetime to use for selecting temporal index levels.

Returns:

Series of values for the specified tariff, indexed by the given timestamps.

fetch_indexed(name: str, timestamps: pandas.DatetimeIndex) pandas.Series[source]

Fetch collection of tariff values, relevant to the given timestamps.

Parameters:
  • name – Name of the tariff.

  • timestamps – Datetime to use for selecting temporal index levels.

Returns:

Series of tariff values, maintaining its original index, pre-selected with only the relevant values .

annular.tariffs.filter_dataframe(data: pandas.DataFrame, select: collections.abc.Mapping[str, str | int]) pandas.Series | numbers.Real[source]

Filter a dataframe by multiple columns.

Example

Preselect {"A": "high", "B": "old"} with data =

A

B

C

value

high

new

yes

1

high

new

no

2

high

old

yes

3

high

old

no

4

low

new

yes

5

low

new

no

6

low

old

yes

7

low

old

no

8

Result:

C

value

yes

3

no

4

Parameters:
  • data – pandas DataFrame to filter. Must have at least one column named ‘value’.

  • select – Dictionary where keys are strings or integers, used to select only the desired rows from the given data. If a key is present as a column name, then only those rows are kept where that column matches the matching value from this dictionary.

Returns:

A pd.Series of the value column, where rows are filtered based on matching values in select. Any columns that were filtered on are removed, and any remaining columns are used as a pd.MultiIndex. If the series only consists of a single row, then it only returns the value.

annular.tariffs.parse_weekday_weekend(date: datetime.date) str[source]

Parse the weekday weekend from a date.

Parameters:

date – Date to parse.

Returns:

Whether the given date is a weekday or a weekend day.

annular.tariffs.is_dutch_holiday(date: datetime.date) bool[source]

Check if date is a Dutch holiday, if not already a weekend by definition.

As of 2013, Dutch holidays are: - New Year’s Day - Good Friday - Easter (Sunday and Monday) - King’s Day - Ascension Day - Pentecost (sunday and Monday) - Christmas (25th and 26th)

Parameters:

date – Date to check.

Returns:

True if the given date is a Dutch holiday, False otherwise.