teehr.TEEHRDataFrameAccessor#

class teehr.TEEHRDataFrameAccessor(pandas_obj)[source]#

Bases: object

Extends pandas DataFrame objects with visualization methods.

Notes

This class contains example methods for summarizing and plotting metrics as well as timeseries. This requires more validation in each method to ensure the DataFrame has the appropriate data.

Methods operating on metrics data should start with ‘metrics’ and methods operating on timeseries data should start with ‘timeseries’.

Methods

location_attributes_map

Generate location_attributes table map.

location_crosswalks_map

Generate location_crosswalks table map.

locations_map

Generate a location map and save it to the specified directory.

timeseries_plot

Generate and save TS plots for each unique variable in theDataFrame.

location_attributes_map(output_dir=None)[source]#

Generate location_attributes table map.

Generate a map of location attributes and save it to the specified directory.

This function checks the table type to ensure it is ‘location_attributes’. If an output directory is specified, it checks if the directory exists and creates it if it does not. It then formats the point data and generates the map.

Parameters:

output_dir (Path or None, optional) – The directory where the generated map will be saved. If None, the map will not be saved to a file. Default is None.

Raises:

AttributeError – If the table type is not ‘location_attributes’.

Notes

This function relies on the following methods:

  • _location_attributes_format_points: Formats the point data.

  • _location_attributes_generate_map: Generates the map using the

    formatted data.

Examples

>>> obj = YourClass()
>>> obj.location_attributes_map(output_dir=Path('/path/to/save'))
location_crosswalks_map(output_dir=None)[source]#

Generate location_crosswalks table map.

Generate a map of location crosswalks and save it to the specified directory.

This method checks the table type to ensure it is ‘location_crosswalks’. If an output directory is specified, it checks if the directory exists and creates it if it does not. It then assembles the point data and generates the map.

Parameters:

output_dir (Path or None, optional) – The directory where the generated map will be saved. If None, the map will not be saved to a file. Default is None.

Raises:

AttributeError – If the table type is not ‘location_crosswalks’.

Notes

This method relies on the following methods:

  • _location_crosswalks_format_points: Assembles the point data.

  • _location_crosswalks_generate_map: Generates the map using the

    assembled data.

Examples

>>> obj = YourClass()
>>> obj.location_crosswalks_map(output_dir=Path('/path/to/save'))
locations_map(output_dir=None)[source]#

Generate a location map and save it to the specified directory.

Parameters:

output_dir (str or Path, optional) – The directory where the generated map will be saved. If not provided, the map will not be saved. If the directory does not exist, it will be created.

Raises:

AttributeError – If the table type is not ‘locations’.

Notes

This function checks the table type to ensure it is ‘locations’. If an output directory is specified, it checks if the directory exists and creates it if it does not. The function then formats the location points and generates the map, saving it to the specified directory if provided.

timeseries_plot(output_dir=None)[source]#

Generate and save TS plots for each unique variable in theDataFrame.

This method generates timeseries plots for each unique variable in the DataFrame’s ‘variable_name’ column. The plots are saved to the specified output directory if provided. If the output directory does not exist, it will be created.

Parameters:

output_dir (pathlib.Path or None, optional) – The directory where the plots will be saved. If None, the plots will be displayed interactively. Default is None.

Returns:

None

Notes

This method calls _timeseries_schema to get the plotting schema and _timeseries_generate_plot to generate each plot. It ensures the output directory exists before saving the plots.