Decorators#

Module Contents#

Classes Summary#

DayBeginOffset

FiveMinOffset

HourBeginOffset

MonthBeginOffset

support_date_range

Decorator that enables automatic date range splitting and iteration.

YearBeginOffset

Functions#

date_range_maker(→ List[pandas.Timestamp])

Generate a date range based on start and end dates and a frequency.

pjm_update_dates(→ List[pandas.Timestamp | None])

PJM has a weird API. This method updates the date range list to account

Attributes Summary#

P

T

Contents#

gridstatus.decorators.date_range_maker(start: pandas.Timestamp, end: pandas.Timestamp, freq: str | pandas.DateOffset, inclusive: str = 'neither') List[pandas.Timestamp][source]#

Generate a date range based on start and end dates and a frequency.

class gridstatus.decorators.DayBeginOffset[source]#

Methods

__ladd__(→ pandas.Timestamp)

__radd__(→ pandas.Timestamp)

__ladd__(other: pandas.Timestamp) pandas.Timestamp[source]#
__radd__(other: pandas.Timestamp) pandas.Timestamp[source]#
class gridstatus.decorators.FiveMinOffset[source]#

Methods

__ladd__(→ pandas.Timestamp)

__radd__(→ pandas.Timestamp)

__ladd__(other: pandas.Timestamp) pandas.Timestamp[source]#
__radd__(other: pandas.Timestamp) pandas.Timestamp[source]#
class gridstatus.decorators.HourBeginOffset[source]#

Methods

__ladd__(→ pandas.Timestamp)

__radd__(→ pandas.Timestamp)

__ladd__(other: pandas.Timestamp) pandas.Timestamp[source]#
__radd__(other: pandas.Timestamp) pandas.Timestamp[source]#
class gridstatus.decorators.MonthBeginOffset[source]#

Methods

__ladd__(→ pandas.Timestamp)

__radd__(→ pandas.Timestamp)

__ladd__(other: pandas.Timestamp) pandas.Timestamp[source]#
__radd__(other: pandas.Timestamp) pandas.Timestamp[source]#
gridstatus.decorators.P[source]#
gridstatus.decorators.pjm_update_dates(dates: List[pandas.Timestamp | None], args_dict: Dict[str, Any]) List[pandas.Timestamp | None][source]#

PJM has a weird API. This method updates the date range list to account for the following restrictions:

  • date ranges cannot span year boundaries

  • date ranges cannot span archive / standard boundaries

  • date range is inclusive of start and end dates

class gridstatus.decorators.support_date_range(frequency: str | Callable[[Dict[str, Any]], str] | None, update_dates: Callable[[List[pandas.Timestamp | None], Dict[str, Any]], List[pandas.Timestamp | None]] | None = None, return_raw: bool = False)[source]#

Decorator that enables automatic date range splitting and iteration.

This decorator automatically splits large date ranges into smaller chunks based on the specified frequency, calls the decorated function for each chunk, and combines the results.

Parameters:
  • frequency – Maximum frequency for splitting date ranges. Common values are “DAY_START” (split by day), “HOUR_START” (split by hour), “5_MIN” (split by 5 minute intervals), “MONTH_START” (split by month), “YEAR_START” (split by year), or None (no splitting, pass date range as-is).

  • update_dates – Optional callback to customize date range splitting logic.

  • return_raw – If True, return list of results instead of concatenating.

The decorated functions also accept these keyword arguments:

  • error (str): Error handling mode. Default is “ignore” which prints errors and continues. Use “raise” to raise errors immediately.

  • save_to (str): Directory path to save results as CSV files. Creates directory if needed.

  • start: Alternative parameter name for ‘date’ (automatically converted).

Example:

@support_date_range(frequency="DAY_START")
def get_data(self, date, end=None, verbose=False):
    # Function is called once per day in the range
    return fetch_data_for_date(date)

# Usage:
df = iso.get_data(date="2024-01-01", end="2024-01-10", error="raise")
# Calls get_data for each day and concatenates results

Attributes

frequency

None

return_raw

False

update_dates

None

Methods

__call__(→ Callable[P, T])

__call__(f: Callable[P, T]) Callable[P, T][source]#
gridstatus.decorators.T[source]#
class gridstatus.decorators.YearBeginOffset[source]#

Methods

__ladd__(→ pandas.Timestamp)

__radd__(→ pandas.Timestamp)

__ladd__(other: pandas.Timestamp) pandas.Timestamp[source]#
__radd__(other: pandas.Timestamp) pandas.Timestamp[source]#