Skip to main content

Pandas DataFrame subclasses that enforce structure and can self-organize.

Project description

Typed DataFrames

Build status Latest version on PyPi Supported Python versions Documentation status Build & test License

Pandas DataFrame subclasses that enforce structure and can self-organize. Because your functions can’t exactly accept any DataFrame. See the docs for more information.

Simple example for a CSV like this:

key value note
abc 123 ?
from typing import Sequence
from typeddfs import SimpleFrame, OrganizingFrame

class KeyValue(OrganizingFrame):

    @classmethod
    def required_index_names(cls) -> Sequence[str]:
        return ['key']

    @classmethod
    def required_columns(cls) -> Sequence[str]:
        return ['value']

    @classmethod
    def reserved_columns(cls) -> Sequence[str]:
        return ['note']

# will self-organizing and use 'key' as the index
df = KeyValue.read_csv('example.csv')
print(df.index.names, list(df.columns))  # ['key'], ['value', 'note']

New issues and pull requests are welcome. Please refer to the contributing guide. Generated with Tyrannosaurus: tyrannosaurus new typed-dfs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typeddfs-0.1.0.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

typeddfs-0.1.0-py3-none-any.whl (9.9 kB view hashes)

Uploaded Python 3

Supported by

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