Skip to content

Utilities

Two helpers under AeroViz.tools, exported at package level.

DataBase

from AeroViz import DataBase

df = DataBase(file_path)                 # any CSV: index column 0, parsed as dates
df = DataBase(load_data=True)            # bundled Tunghai chemistry / optical dataset
psd = DataBase(load_PSD=True)            # bundled PNSD dataset

DataBase(file_path=None, load_data=False, load_PSD=False) is a loader, not a class you keep around — calling it returns a DataFrame. With file_path it reads that CSV (na_values=('E', 'F', '-', '_', '#', '*'), index_col=0, parse_dates=True). Without a path, exactly one of load_data / load_PSD must be True; it then loads the bundled local dataset (Tunghai or PNSD).

DataClassifier

from AeroViz import DataClassifier

mean_df, std_df = DataClassifier(df, by='Season')
mean_df, std_df = DataClassifier(df, by='WS', cut_bins=[0, 2, 4, 6, 10])
mean_df, std_df = DataClassifier(df, by='PM25', qcut=4, labels=['Q1', 'Q2', 'Q3', 'Q4'])

DataClassifier(df, by, df_support=None, cut_bins=None, qcut=None, labels=None) groups a DataFrame and returns two DataFrames — group means and group standard deviations — shaped for AeroViz.plot.bar / box / violin.

  • by is a built-in grouping ('Hour', 'State', 'Season', 'Season_state') or any column name.
  • If by is not a column of df, pass df_support (a frame carrying the time-indexed variables the built-in groupings are derived from).
  • cut_bins bins a numeric by column at fixed edges; qcut splits it into quantiles; labels names the bins.

API

AeroViz.tools.DataBase

Methods:

__new__

__new__(file_path: Path | str = None, load_data: bool = False, load_PSD: bool = False)

AeroViz.tools.DataClassifier

Bases: Classifier

Notes

First, create group then return the selected statistic method. If the 'by' does not exist in DataFrame, import the default DataFrame to help to sign the different group.

Methods:

__new__

__new__(df: DataFrame, by: Literal['Hour', 'State', 'Season', 'Season_state'] | str, df_support: DataFrame | Series = None, cut_bins: Sequence = None, qcut: int = None, labels: list[str] = None) -> tuple[DataFrame, DataFrame]

_group_data staticmethod

_group_data(df, by, df_support, cut_bins, qcut, labels)

_compute_statistics staticmethod

_compute_statistics(df, group)