Skip to main content

Draft implementation of the DataFrame Standard for pandas and polars

Project description

Build Status Coverage pre-commit.ci status

DataFrame Standard POC

standard-compliant DataFrame

Work-in-progress POC of what the DataFrame Standard might look like for pandas and polars.

What's this?

Please read our blog post! https://data-apis.org/blog/dataframe_standard_rfc/.

How to try this out

Here's an example of how you can try this out:

import pandas as pd
from dataframe_api_compat import pandas_standard
from dataframe_api_compat import polars_standard

def convert_to_standard_compliant_dataframe(df):
    if isinstance(df, pd.DataFrame):
        return pandas_standard.convert_to_standard_compliant_dataframe(df)
    elif isinstance(df, pl.DataFrame):
        return polars_standard.convert_to_standard_compliant_dataframe(df)
    else:
        raise TypeError(f"Got unexpected type: {type(df)}")

df = pd.DataFrame({'a': [1,2,3]})
df_std = convert_to_standard_compliant_dataframe(df)

The object df_std is a Standard-compliant DataFrame.

Installation

pip install git+https://github.com/MarcoGorelli/dataframe-api-compat

Testing

pytest --cov=dataframe_api_compat --cov=test_standard --cov-fail-under=100

100% branch coverage isn't the objective - it's the bare minimum.

Linting

pre-commit run --all-files

Type Checking

First, clone the dataframe_standard to some local path. Then, run:

MYPYPATH=<path to dataframe-api/spec/API_specification> mypy dataframe_api_compat
MYPYPATH=<path to dataframe-api/spec/API_specification> mypy polars_standard.py

For example, if you cloned both repos in the same place, this could be:

MYPYPATH=../dataframe-api/spec/API_specification/ mypy dataframe_api_compat

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

dataframe_api_compat-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

dataframe_api_compat-0.1.0-py2.py3-none-any.whl (11.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dataframe_api_compat-0.1.0.tar.gz.

File metadata

  • Download URL: dataframe_api_compat-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for dataframe_api_compat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8368212da833ff88ff96fe580f494b05861d872ca1e74bdac8ade010b9d64962
MD5 f824e6e8aee35d6777b97c6d8e0d65b6
BLAKE2b-256 73463d8f9f1512e03e1571db5d5b6c2555075deb48ab452fc96cf6f438c2a790

See more details on using hashes here.

File details

Details for the file dataframe_api_compat-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dataframe_api_compat-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c2bd4df06bb7827aec993ae37ff402cd1fa6d20504f969ac18c9fbbc05eeaf3f
MD5 4e8ea60e80ea5c1316fcf6597e387dd2
BLAKE2b-256 fc910db06c236ca6093010494402039451eb221469d09162e46293d36e53ebfc

See more details on using hashes here.

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