Skip to main content

A package for aggregating and merging US geographic data frames.

Project description

USAggregate

USAggregate is a Python package for aggregating and merging US relational data frames.

Example Use Case

Merging demographic data at the zip code level with ice cream sales data at the city level to measure the correlation between demographics and ice cream sales at the county level.

Installation

You can install the package using pip:

pip install USAggregate

Use Notes

zip codes in your data sets should be converted to strings before applying 'usaggregate' function. Numeric option will be available in a later version. Convert respect geographic identifiers to 'zip', 'city', 'county' and/or 'state' before applying 'usaggregate' function. Capabilities to handle other column names will be available in a later version. Function is only available for cross-sectional data. Panel data capabilities will be available in a later version.

Below is an example of package usage.

import pandas as pd
from USAggregate import usaggregate

data_zip = pd.DataFrame({
    'zip': ['98199', '98103', '98001', '98002', '91360', '91358', '93001', '93003'],
    'value1': [1, 2, 3, 4, 5, 6, 7, 8],
    'chr1': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
    })

data_city = pd.DataFrame({
        'city': ['Seattle', 'Auburn', 'Thousand Oaks', 'Ventura'],
        'state': ['WA', 'WA', 'CA', 'CA'],
        'value2': [1, 2, 3, 4],
        'chr2' : ['I', 'J', 'K', 'L']
    })

data_county = pd.DataFrame({
        'county': ['King County', 'Ventura County'],
        'state': ['Washington', 'California'],
        'value3': [5, 6],
        'chr3': ['M', 'N']
    })

# Using the function
result = usaggregate([data_zip, data_city, data_county], level='state', agg_numeric='sum', agg_character='first')
print(result)

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

If you're not sure about the file name format, learn more about wheel file names.

USAggregate-1.0.4-py3-none-any.whl (325.8 kB view details)

Uploaded Python 3

File details

Details for the file USAggregate-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: USAggregate-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 325.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for USAggregate-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 89805beaf143d0023eabad9597b00f713239a454ec6055f6f3b3cc86f504b4e5
MD5 582bad5ac6ca89b5fea370b6c0ae1428
BLAKE2b-256 023748543659a516eb44acb0c910f85841bc4c85cbae8836092e1d835eea7af5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page