Package: dataframe-handlers
This README was produced byAnthropic's Claude LLMdataframe_handlersdataframe_handlersaims 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 theSolaraPython library, which can be used to create reactive web apps using pure Python.Installationhttps://pypi.org/project/dataframe-handlers# any of the followingpipinstalldataframe-handlers
pipinstalldataframe-handlers[pandas]pipinstalldataframe-handlers[dask]pipinstalldataframe-handlers[xarray]# pip install dataframe-handlers[vaex]pipinstalldataframe-handlers[testing]pipinstalldataframe-handlers[pandas,xarray,testing]UsageThe base class,BaseDataFrameHandler, defines an abstract interface with the following methods:get_unique(column: str, limit: Optional[int] = None) -> Collectionget_value_counts(column: str, limit: Optional[int] = None) -> Mapping[str, int]get_data_range(column: str) -> Sequenceget_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 usingdataframe_handlers.get_handler, which will return a handler of the appropriate type based on the type of dataframe it is given.importpandasaspdfromdataframe_handlersimportget_handlerdf=pd.DataFrame({'A':[1,2,3]})handler=get_handler(df)columns=handler.get_columns()# ['A']Libraries built on thedataframe_handlersinterface can then support multiple dataframe types interchangeably.ContributingThere are a few ways you can contribute todataframe_handlersand help guide its future: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.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!Improve existing concrete implementations. More comprehensive testing, performance optimizations and support for newer library versions all help improve the quality of the project.Improve documentation. Additional details on implementing new handlers, more examples, and type hints help make the project more contributor-friendly.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 fordataframe_handlersto 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 seeCONTRIBUTING.md.Licensedataframe_handlersis licensed under the MIT license. See the LICENSE file for details.