fast pandas selction and indexing
Project description
fastIndex
awesome way to select from pandas multi index and more
Warning! this repository is on early develoapment stage!
installation:
pip install fastindex
configuration:
from fastindex import fast_index
import pandas as pd
#expanding pandas with fastindex
fast_index(pd)
example usage:
setting pandas MultiIndex
df = read_csv("data.csv")
df.set_index(["Country","City","District","first_name","Age","ID"],inplace=True)
df.sort_index(inplace=True)
Basic Selection
- Regular Pandas:
df.loc[(slice(None),slice(None),slice(None),slice(None),24),:]
- With fastindex
df.fidx.slice(Age=24)
Ranges
- Regular Pandas:
df.loc[("Spain",slice(None),slice(None),slice(None),slice(23,25)),:]
- With fastindex
df.fidx.slice(Age=slice(23,25),Country="Spain")
Selecting columns
- Regular Pandas:
df.loc[("Spain",slice(None),slice(None),slice(None),slice(23,25)),["last_name"]]
- With fastindex
df.fidx.slice(Age=slice(23,25),Country="Spain",columns = ["last_name"])
setting values using f_slice:
slc = df.fidx.f_slice(Age=slice(23,25),Country="Spain")
df.loc[slc,"last_name"] = "Leonardo"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for fastindex-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a6abd0035549fd826a9f66e2c64ccdd21e7e60303255a6fa2c65857feb0b037 |
|
MD5 | 5bf24dd0158482ddbbcc4cebc4fc032f |
|
BLAKE2b-256 | fa2ae8b84380b9f450c3c4d79fae18ad068fe1cab39408890cbaabb6c36ab1db |