Decorators#
Module Contents#
Classes Summary#
Decorator that enables automatic date range splitting and iteration. |
|
Functions#
|
Generate a date range based on start and end dates and a frequency. |
|
PJM has a weird API. This method updates the date range list to account |
Attributes Summary#
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.
- 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])