pandas-lookup
A port of agate-lookup that provides the lookup in Pandas DataFrames instead of Agate Tables.
This uses lookup tables from Wireservice's lookup project.
Installation
pip install pandas-lookup
Look up a column from a lookup table
When the key in your data is the same as the key in the lookup table:
>>> import pandaslookup
>>> import pandas as pd
>>> df = pd.DataFrame({'usps': ['CT', 'NY', 'NJ']})
>>> print(df)
state_abbr
0 CT
1 NY
2 NJ
>>> df.pipe(pandaslookup.lookup, 'usps', 'state')
usps state
0 CT Connecticut
1 NY New York
2 NJ New Jersey
When the key in your data is different than the key in the lookup table:
>>> import pandaslookup
>>> import pandas as pd
>>> df = pd.DataFrame({'state_abbr': ['CT', 'NY', 'NJ']})
>>> print(df)
state_abbr
0 CT
1 NY
2 NJ
>>> df.pipe(pandaslookup.lookup, 'state_abbr', 'state', lookup_key='usps')
usps state
0 CT Connecticut
1 NY New York
2 NJ New Jersey
Retrieve a table without joining
>>> import pandaslookup
>>> table = pandaslookup.from_lookup(['usps', 'year'], 'population')
>>> print(table.head())
usps year population
0 AL 1970 3454557
1 AL 1971 3497349
2 AL 1972 3540003
3 AL 1973 3580759
4 AL 1974 3627778
Installing for development
pipenv install --dev -e .
Running tests
pipenv run python -m unittest
Prior art
- harbolkn/pandas-lookup: This is the same idea, but it relies on the
agate-lookuppackage, which createds a needless dependency on Agate. Also, I don't think I like monkey-patchingDataFrame.
Metadata
Release files for pandas-lookup 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pandas-lookup-0.1.4.tar.gz | 4.6 kB | Without provenance | Details for pandas-lookup-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandas_lookup-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for pandas_lookup-0.1.4-py3-none-any.whl |
Total release size: 10.6 kB
Release files / pandas-lookup-0.1.4.tar.gz
| Download URL | pandas-lookup-0.1.4.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3c689efc05d9e528f7938a23050abb6650487e679cf27890fa00a0fc30359f9
|
|
BLAKE2b-256 checksum How to use checksums |
4a6736f130788e87f552e389dda1e142a469293920b255918398c334ae16ba95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
|
Release files / pandas_lookup-0.1.4-py3-none-any.whl
| Download URL | pandas_lookup-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b58f6c277ec5f16598624a7991f1171d4da49457f464675c7e34078a28c6f320
|
|
BLAKE2b-256 checksum How to use checksums |
0ba8b700161d7370691143f92f897b79fd7e38a98c993ba289c6a87eef1d47ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
|
Security for pandas-lookup 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.