utils
_to_idx(arr, bins)
Convert an array of values to an array of indices into a set of bins.T
Parameters
arr
A N-dimensional array of values to convert.
bins
A 1-dimensional array of bins. Bins must be sorted, increasing,
and not contain duplicates. Every value in arr will be converted
to an index into bins, with values outside of bins being clipped
to the nearest bin edge. Bins are 0-indexed and left-inclusive,
so idx 0 contains values from -infinity to bins[1], idx 1 contains
values from bins[1] to bins[2], etc.
Returns:
| Type | Description |
|---|---|
|
The array of indices into the bins. |
Source code in src/climate_data/special/utils.py
aggregate_to_hierarchy(data: pd.DataFrame, hierarchy: pd.DataFrame) -> pd.DataFrame
Create all aggregate climate values for a given hierarchy from most-detailed data.
Parameters
data The most-detailed climate data to aggregate. hierarchy The hierarchy to aggregate the data to.
Returns
pd.DataFrame The climate data with values for all levels of the hierarchy.