pandas-lookup adds remote lookup tables to a Pandas DataFrame.
Project description
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
>>> import pandaslookup
>>> import pandas as pd
>>> df = pd.DataFrame({'state_abbr': ['CT', 'NY', 'NJ']})
>>> print(df)
state_abbr
0 CT
1 NY
2 NJ
>>> import pandaslookup
>>> import pandas as pd
>>> df = pd.DataFrame({'state_abbr': ['CT', 'NY', 'NJ']})
>>> print(df)
state_abbr
0 CT
1 NY
2 NJ
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-lookup
package, which createds a needless dependency on Agate. Also, I don't think I like monkey-patchingDataFrame
.
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
pandas-lookup-0.1.3.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for pandas_lookup-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 695590198cba43b50e76d8d8d67684e7f970d285669339b55f01b54336d94bdd |
|
MD5 | 3ae7acdf1b463d7a17ec2c252e718f5a |
|
BLAKE2b-256 | bd188600de1aa9623c8b83a9d7bd890d92a66cfca100651f6953abbfe0737f80 |