Helpers to facilitate working with pandas indices in particular multiindices
Project description
Summary
pandas-indexing is a helpers package to make interacting with pandas multi-indices less painful. It contains functions, that
filter easily into multi indices: isin, ismatch
add or update levels in a multiindex: assignlevel
select one or multiple specific levels: projectlevel
Usage
Given you have a time-series like dataframe with several multi index levels, like model, scenario, variable: then you can select a subset with:
df.loc[isin(model="m1", scenario=["s1", "s2"])]
or with shell like glob-patterns:
df.loc[
ismatch(
model="REMIND*", variable="Emissions|**", unit=["Mt CO2/yr", "kt N2O/yr"]
)
]
You can overwrite index levels:
assignlevel(df, selected=1)
or project your data to only a few desired index levels:
projectlevel(df, ["model", "scenario"])
All commands are described in detail in the API reference in documentation and are togehter with introductions for installing and using this package, but they are mostly bare-bones atm.
Issues and Discussions
As usual for any GitHub-based project, raise an issue if you find any bug or want to suggest an improvement, or open a discussion if you want to discuss.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pandas_indexing-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 592d4a8c8d041911bdbc1dccc243e7b0b20bbf893728cbab19b898c5fe3fe5da |
|
MD5 | 7c946e575135877fa4c72c1256e17391 |
|
BLAKE2b-256 | 31ed3f0b9265f3e9356b6b297394d31b9a1059f8d2e8f74fd38a0ded31bc095d |