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
Generate a location map and save it to the specified directory.
Generate and save TS plots for each unique variable in theDataFrame.
- location_map(output_dir=None)[source]#
Generate a location map and save it to the specified directory.
- Parameters:
output_dir (
str
orPath
, 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
orNone
, 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.