Skip to main content

Cartwright

Tests

Cartwright is a data profiler that identifies and categorizes spatial and temporal features. Cartwright uses deep learning, natural language processing, and a variety of heuristics to determine whether a column in a dataset contains spatial or temporal information and, if so, what is specifically contained.

Cartwright was built to automate complex data pipelines for heterogenous climate and geopolitical data that are generally oriented around geospatial and temporal features (think maps and time series). The challenge that Cartwright solves is automatically detecting those features so they can be parsed and normalized. This problem turns out to be quite tricky, but Cartwright makes it simple.

Cartwright can easily detect things like country, day, latitude, and many other location and time types. Check out Cartwright's supported categories for a complete listing!

Cartwright is easy to install and works with pretty much any tabular data. It's easy to add new categories too! Learn more about the methodology behind Cartwright, its API, and how to contribute in our docs.

Installation

You can install Cartwright from PyPi with pip install cartwright.

Using Cartwright

Imagine we have the following weather dataset:

x_value y_value recorded_at rainfall
7.942658 107.240322 07/14/1992 .2
7.943745 137.240633 07/15/1992 .1
7.943725 139.240664 07/16/1992 .3

To the human observer, it's pretty obvious that x_value is the longitude column, y_value the latitude, recorded_at the date, and rainfall the actual weather measurement. However, if we're trying to automatically ingest this data into a weather model, we would benefit from knowing this without human observation. Enter Cartwright:

from pprint import pprint
from cartwright import categorize

cartwright = categorize.CartwrightClassify()
categories = cartwright.categorize(path="path/to/data.csv")

pprint(categories, sort_dicts=False)

We've now categoriezed each column in this dataset and have automatically determined which column represents latitude, longitude and date. We've also learned the time format (%m/%d/%Y) of the date feature.

{'x_value': {'category': <Category.geo: 'geo'>,
             'subcategory': <Subcategory.longitude: 'longitude'>,
             'format': None},
 'y_value': {'category': <Category.geo: 'geo'>,
             'subcategory': <Subcategory.latitude: 'latitude'>,
             'format': None},
 'recorded_at': {'category': <Category.time: 'time'>,
                'subcategory': <Subcategory.date: 'date'>,
                'format': '%m/%d/%Y'}}

With this information we can now convert the date values to a timestamp and plot a timeseries with other features.

Resolution Detection

In addition to its ability to categorize spatial and temporal features, Cartwright can determine their resolution. For example, given a dataset like:

date,temperature(C)
2019-01-01 00:00:00, 10.2
2019-01-01 02:00:00, 11.7
2019-01-01 04:00:00, 12.3
...
2019-12-31 22:00:00, 10.1

Cartwright can detect it's temporal resolution:

Resolution(
    uniformity=Uniformity.PERFECT,
    unit=TimeUnit.HOUR,
    resolution=2.0,
    error=0.0,
)

For gridded data, which is common in the scientific domain, Cartwright can also determine the spatial resolution (grid size). Check out the docs to learn more about using Cartwright to detect temporal resolution and spatial resolution.

Metadata

Release files for cartwright 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cartwright 0.0.3
File Size Uploaded
cartwright-0.0.3.tar.gz 501.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cartwright 0.0.3
File Interpreter ABI Platform
cartwright-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / cartwright-0.0.3.tar.gz

Download URL cartwright-0.0.3.tar.gz
Size 501.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9b020e28953ca128b8d1d04bb5dffc15a871a81f18272d1c967dbc501d01f085
BLAKE2b-256 checksum
How to use checksums
dee95c5af9debef4dc0616916e6cb79f50770bd01f1ca631403e34cb42531541
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.8.15 Linux/5.15.0-52-generic

Release files / cartwright-0.0.3-py3-none-any.whl

Download URL cartwright-0.0.3-py3-none-any.whl
Size 504.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ec2402e42a7b282feef2d0075c5e110a9c30313e3b87ac22dd15b335f50dcc2
BLAKE2b-256 checksum
How to use checksums
65f759fd492d879e7ef793f60fe44a13aba35cb27b86d411039cddc89f9b324d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.8.15 Linux/5.15.0-52-generic

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page