ebm.model.data_classes module

class ScurveParameters(building_category: str, condition: str, earliest_age: int, average_age: int, rush_years: int, last_age: int, rush_share: float, never_share: float)[source]

Bases: object

building_category: str
condition: str
earliest_age: int
average_age: int
rush_years: int
last_age: int
rush_share: float
never_share: float
__init__(building_category: str, condition: str, earliest_age: int, average_age: int, rush_years: int, last_age: int, rush_share: float, never_share: float) None
class TEKParameters(tek: str, building_year: int, start_year: int, end_year: int)[source]

Bases: object

tek: str
building_year: int
start_year: int
end_year: int
__init__(tek: str, building_year: int, start_year: int, end_year: int) None
class YearRange(start: int, end: int, year_range: Tuple[int] = ())[source]

Bases: object

A class to represent a period model with a start and end year.

Attributes

startint

The starting year of the period.

endint

The ending year of the period.

year_rangetuple of int

A tuple containing all years in the period from start to end (inclusive).

Methods

__post_init__():

Initializes the years attribute after the object is created.

__iter__():

Returns an iterator over the years in the period.

range() -> tuple of int:

Returns a tuple of years from start to end (inclusive).

subset(offset: int = 0, length: int = -1) -> ‘YearRange’:

Creates a subset YearRange of this year range.

to_index() -> pd.Index:

Converts the year_range to a pandas Index.

Examples

Slice pandas DataFrame with YearRange.

>>> df = pd.DataFrame(data=['first', 'b', 'c', 'd', 'last'],
...                   index=[2010, 2011, 2012, 2013, 2014])
>>> years = YearRange(2011, 2013)
>>> df.loc[years]
      0
2011  b
2012  c
2013  d
>>>
start: int
end: int
year_range: Tuple[int] = ()
range() Tuple[int][source]

Returns a tuple of years from start to end for use with indexes and such.

Returns

tuple of int

Tuple containing all years in sequence from start to end (inclusive).

subset(offset: int = 0, length: int = -1) YearRange[source]

Creates a subset YearRange of this year range.

Parameters

offsetint

How many years to skip after the first year.

lengthint, optional

How many years to return after the offset. When -1, all remaining years are returned. Default: -1

Returns

year_range : YearRange

Raises

ValueError

When offset is less than 0 or offset is greater than the number of years in the YearRange.

Examples

>>> YearRange(2010, 2016).subset(2,3)
YearRange(start=2012, end=2014, year_range=(2012, 2013, 2014))
>>> YearRange(2010, 2016).subset(2,-1)
YearRange(start=2012, end=2016, year_range=(2012, 2013, 2014, 2015, 2016))
>>> YearRange(2010, 2016).subset(3)
YearRange(start=2013, end=2016, year_range=(2013, 2014, 2015, 2016))
to_index(name='year') Index[source]

Converts the year_range to a pandas Index. Parameters ———- name : str, optional

name of the index. Default: ‘name’

Returns

pd.Index

Pandas Index object containing the years in the range.

to_dataframe(name='year') DataFrame[source]

Converts the year_range to a pandas DataFrame. Parameters ———- name : str, optional

name of the column. Default: ‘year’

Returns

pd.DataFrame

Pandas Dataframe object containing the years in the range in the column year.

cross_join(df: DataFrame) DataFrame[source]

Join every row in df with every year in a YearRange

Parameters

dfpd.DataFrame

dataframe to join with YearRange

Returns

pd.DataFrame

Pandas Dataframe containing the original dataframe and a year column

static from_series(s: Series)[source]
__init__(start: int, end: int, year_range: Tuple[int] = ()) None