Skip to main content

This README was produced by Anthropic's Claude LLM

dataframe_handlers

License: MIT python security: bandit Ruff Code style: black pre-commit Checked with mypy Test coverage

dataframe_handlers aims to provide an abstract base class and concrete implementations for handling and manipulating dataframes of various types in Python. While the interface may be applicable to many use cases, the immediate goal is to standardize interaction with dataframe libraries and enable interoperability between them in the context of the Solara Python library, which can be used to create reactive web apps using pure Python.

Installation

https://pypi.org/project/dataframe-handlers

# any of the following

pip install dataframe-handlers
pip install dataframe-handlers[pandas]
pip install dataframe-handlers[dask]
pip install dataframe-handlers[xarray]
# pip install dataframe-handlers[vaex]
pip install dataframe-handlers[testing]

pip install dataframe-handlers[pandas,xarray,testing]

Usage

The base class, BaseDataFrameHandler, defines an abstract interface with the following methods:

  • get_unique(column: str, limit: Optional[int] = None) -> Collection
  • get_value_counts(column: str, limit: Optional[int] = None) -> Mapping[str, int]
  • get_data_range(column: str) -> Sequence
  • get_missing_filter(column: str) -> Sequence[bool]
  • get_value_filter(column: str, values: list, invert: bool = False) -> Sequence[bool]
  • get_columns() -> Collection[str]
  • get_numeric_columns() -> Collection[str]
  • get_column_types(default_str: bool = True) -> Mapping[str, Union[object, type, str]]

Concrete implementations of this interface exist for:

  • Pandas (PandasDataFrameHandler)
  • Dask (DaskDataFrameHandler)
  • Xarray (XarrayDataFrameHandler)
  • Vaex (VaexDataFrameHandler, currently disabled)

The easiest way to get a handler does not require knowing what type of dataframe you're dealing with.

You can do this by using dataframe_handlers.get_handler, which will return a handler of the appropriate type based on the type of dataframe it is given.

import pandas as pd
from dataframe_handlers import get_handler

df = pd.DataFrame({'A': [1, 2, 3]})
handler = get_handler(df)

columns = handler.get_columns()
# ['A']

Libraries built on the dataframe_handlers interface can then support multiple dataframe types interchangeably.

Contributing

There are a few ways you can contribute to dataframe_handlers and help guide its future:

  1. Add support for another dataframe library by implementing a new concrete handler class. This helps expand the scope of the project and allows it to support new use cases.

  2. Improve or expand the abstract base interface. As new methods are identified to broadly support dataframe interaction and manipulation, the interface can be expanded. However, we aim to keep the interface as concise as possible to facilitate implementation for many types. User feedback on what methods/functionality would be most useful to support is appreciated!

  3. Improve existing concrete implementations. More comprehensive testing, performance optimizations and support for newer library versions all help improve the quality of the project.

  4. Improve documentation. Additional details on implementing new handlers, more examples, and type hints help make the project more contributor-friendly.

  5. Improve validation. Stricter checks that subclasses implement the required methods, consistent method signatures, and edge case testing all help users build on the interface.

We aim for dataframe_handlers to be a community project guided by user needs and feedback. Please feel free to open issues or start a discussion to propose new ideas, give feedback on the direction of the project or interface design, or submit pull requests with your contributions and improvements!

For specific instructions, please see CONTRIBUTING.md.

License

dataframe_handlers is licensed under the MIT license. See the LICENSE file for details.

Metadata

Release files for dataframe-handlers 0.0.5

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

Source distribution (sdist)

Source distribution for dataframe-handlers 0.0.5
File Size Uploaded
dataframe_handlers-0.0.5.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataframe-handlers 0.0.5
File Interpreter ABI Platform
dataframe_handlers-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 27.1 kB

Release files / dataframe_handlers-0.0.5.tar.gz

Download URL dataframe_handlers-0.0.5.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dae43c4467e313294c7de86ddc786b1c408512110f1cc6e7bcba8cbaefac6e6c
BLAKE2b-256 checksum
How to use checksums
711899d74442c25e6e1ceec672ce5925dcfa567bd3a2fc0a3eeb5b3c119db234
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / dataframe_handlers-0.0.5-py3-none-any.whl

Download URL dataframe_handlers-0.0.5-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af5d1d635d063380e89dc3acb0cd21f7acd403f2a746224023db77db8fdcde42
BLAKE2b-256 checksum
How to use checksums
7a7b9ed71bd90083115d85b71eeb7d6712a2f60ccf76e45e205cf75375236752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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