Changelog
v0.6.2 (2024-02-26)
Make
semijoin()andantijoin()accept a Series or DataFrame argument to join against PR64Add py.typed file to signal available type hints to downstream packages PR63
Special thanks to @znichollscr for his first contribution.
v0.6.1 (2024-12-01)
Fix
iamc_aggregate()to return NaN instead of 0 if no sub-sectors exist.
v0.6.0 (2024-10-24)
Add
resolvermodule with the classResolverthat supports consolidating IAMC-style scenario data with non-homogeneous variable coverage. Documentation is unfortunately still missing.Add support for so-called optional patterns to
extractlevel()andformatlevel(), for instance:df.pix.extract(variable="Emissions|{gas}|{sector}", optional=["sector"])decomposesEmissions|CO2into{"gas": "CO2", "sector": "Total"}.
v0.5.2 (2024-08-24)
Bumps minimum python version to 3.9 (which is close to EOL, anyway)
Improve
selectorsto arbitrarily interact with boolean Series, numpy arrays and callables, ie. 1.pd.Series([True, False]) & isin(model="a")produces the same result asisin(model="a") & pd.Series([True, False])did earlier.isin(model="a") & (lambda s: s > 2)is now supported as well.
Fix a testing incompability introduced by a recent attrs update (24.1.0)
Load pint and pint-pandas packages only on first use
v0.5.1 (2024-05-20)
v0.5.0 (2024-04-09)
BREAKING: Change
extractlevel()to drop split levels by default and accordingly rename the governing argument fromdrop=Falsetokeep=FalsePR53.Add
regex=Trueargument toextractlevel()to use templates as manual extraction regex, f.ex.df.pix.extract(variable=r"Emissions\|(?P<gas>.*?)(?:\|(?P<sector>.*?))?", regex=True)will also splitEmissions|CO2togas = "CO2"andsector = NaN, whiledf.pix.extract(variable="Emissions|{gas}|{sector}")would have dropped it.Update
projectlevel()to raiseKeyErrorfor wrong level names PR52.
v0.4.2 (2024-04-03)
Add
add_zeros_like()for adding explicitlevelsas 0 values PR51
v0.4.1 (2024-03-20)
Add
antijoin()for performing anti-joins PR48Update usage guide for
antijoin, but also with more focus onextractlevel
v0.4.0 (2023-12-12)
BREAKING
accessorsis imported implicitly. User code does not need to import it any longer PR45Add continuous testing for python 3.12 PR47
Add
AllandNone_completing selector group PR46Fix type hints of function
aggregatelevel()PR44Switch from black to ruff for formatting and update pre-commit versions PR43
v0.3.1 (2023-09-18)
The new
assignlevel()argumentignore_index=Trueprevents the dataframe and series alignment which became the default in v0.3 (yesterday), since there are valid use cases of the old behaviour PR41
v0.3 (2023-09-17)
v0.2.10 (2023-08-31)
Add
mode="append"andmode="return"arguments toaggregatelevel(), which extend the dataframe with the aggregated data or return it PR39Add
fail_on_reorderargument tosemijoin()to raise aValueErrorif the resulting data is not in the order of the provided index (helpful in conjunction withassignlevel()) PR37Enhance
concat()to also concatenateIndexandMultiIndexobjects PR37
v0.2.10-b1 (2023-07-26)
Revise
arithmeticsmodule:Add all standard binary ops:
add,sub,mul,pow,mod,floordiv,truediv,divmod,radd,rsub,rmul,rpow,rmod,rfloordiv,rtruediv,rdivmodSupport in-call assignment of individual levels using
assignargument, likediv(generation, capacity, assign=dict(variable="capacity_factor"))Add a unit-aware variant for each binary op, like
unitadd(), orunitmul(), which updates homogeneous units automatically with the calculation
Add
fill_valueargument tosemijoin()for filling joining gapsAdd
aggregatelevel()for aggregating individual level labels; in PR32Fix
formatlevel()to create a simple single-level index, if only a single index remains PR29Add
to_tidy()for converting a time-series data-frame to tidy format, as expected by plotting libraries like seaborn or plotly express; in PR31.
v0.2.9 (2023-07-11)
Rename pandas accessor to
.pix(.idxis as of now deprecated, but available for the time being) in PR27.Fix
projectlevel()on columns of aDataFramePR28
v0.2.8 (2023-06-24)
Units can be converted with
convert_unit(), like f.ex.convert_unit(df, "km / h")or withconvert_unit(df, {"m / s": "km / h"})to convert only data with them / sunitIf the openscm-units registry is registered as pint application registry then emission conversion between gas species are possible under the correct contexts:
from pandas_indexing import set_openscm_registry_as_default, convert_unit
ur = set_openscm_registry_as_default()
with ur.context("AR6GWP100"):
df = convert_unit(df, "Mt CO2e/yr") # or df = df.idx.convert_unit("Mt CO2e/yr")
To use unit conversion, you should install with
pip install "pandas-indexing[units]"to pull in the optionalpintandopenscm-unitsdependenciesFor more information about unit handling, refer to
unitsor check the code added in PR17Documentation fixes: MyST notebook rendering from PR20 and new docs for
extractlevel()in PR21.Bug fixes:
semijoin(),concat()andismatch()are working again as advertised PR21 and PR24.
v0.2.7 (2023-05-26)
Compatibility release to re-include Python 3.8 support and fix CI testing
extract()gains single-level index supportMinimal doc improvements
v0.2.6 (2023-05-25)
v0.2.5 (2023-05-04)
formatlevel()andextractlevel()(or their equivalentsformat()andextract()) make it easy to combine or split index levels using format-string like templates; check examples in the guide (Selecting data) PR13describelevel()superseeds the as-of-now deprecatedsummarylevel()PR11
v0.2.4 (2023-05-03)
v0.2.3 (2023-05-03)
uniquelevel()or.idx.uniquereturns the unique values of one or multiple levels. PR8summarylevel()creates a string summarizing the index levels and their values. Can also be accessed asdf.idxorindex.idxPR9
v0.2.2 (2023-05-02)
assignlevel()takes labels from an optional positional dataframe PR5Add
dropnalevel()to remove missing index entries PR4, PR6
v0.2.1 (2023-04-08)
v0.2 (2023-04-07)
isin()andismatch()are now callable objects, which can be composed with the standard~,&and|operators to more complex queriesadd(),subtract(),multiply()anddivide()in the newarithmeticsmodule extend the standard pandas operations withjoinand other arguments known frompandas.DataFrame.align(). They are also available from theidx accessor.Both additions were introduced in PR3
v0.1.2 (2023-02-27)
Add usage guide to documentation
Fix
semijoin()method
v0.1.1 (2023-02-27)
v0.1 (2023-02-23)
Initial release