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
File details
Details for the file pandas_indexing-0.6.0.tar.gz
.
File metadata
- Download URL: pandas_indexing-0.6.0.tar.gz
- Upload date:
- Size: 75.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 316b91cd4e5c681c763b4a2e5b48753c86b610329e917f1c672f05bf09d4448a |
|
MD5 | 872987609b88861b781da2223fc17086 |
|
BLAKE2b-256 | e0b806e8e79d5881c4a1dfa2c0943177bc01b0aad20181d0b178d4c4b351fd53 |
File details
Details for the file pandas_indexing-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: pandas_indexing-0.6.0-py3-none-any.whl
- Upload date:
- Size: 32.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f19a8d8703d0d5ef07ca72743cbffdbee269a458206f009c8374ccd59fcdc5ab |
|
MD5 | a9accdf6bbea540a4859713da169431c |
|
BLAKE2b-256 | 634c468ad1245d8610569a2acb08a88593933a8edca1b4254760f47377b27070 |