Registry / data / pandas-flavor

pandas-flavor

JSON →
library0.8.1pypypi✓ verified 22d ago

pandas-flavor is a Python library that extends Pandas' API by simplifying the process of registering custom methods and accessors directly onto Pandas DataFrames, Series, and GroupBy objects. It makes it easier to add custom functionality, making it backwards compatible with older versions of Pandas. The current version is 0.8.1, and it is actively maintained with a regular release cadence.

pip install pandas-flavor
INSTALL
IMPORT
SIG · PANDAS-FLAVOR
P
pandas-flavor
datapythonv0.8.1
Install
8.8s avg
Import
1422ms
Disk
180MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.442s · 177.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.8s · import 1.402s · 170MB
180MB installed
● package 180MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

register_dataframe_method
from pandas_flavor import register_dataframe_method
register_series_method
from pandas_flavor import register_series_method
register_dataframe_accessor
from pandas_flavor import register_dataframe_accessor
from pandas_flavor import register_dataframe_method # for creating namespaced methods
Use 'register_dataframe_accessor' for creating namespaced accessors with multiple methods, which is often preferred by the Pandas community to avoid global method pollution.
register_series_accessor
from pandas_flavor import register_series_accessor

This quickstart demonstrates how to register a custom method directly onto a Pandas DataFrame using the `@pf.register_dataframe_method` decorator. After registration, the method `filter_by_value` becomes available on any DataFrame instance, allowing for chainable operations similar to built-in Pandas methods.

import pandas as pd import pandas_flavor as pf @pf.register_dataframe_method def filter_by_value(df, column, value): """Filters a DataFrame to rows where 'column' equals 'value'.""" return df[df[column] == value] df = pd.DataFrame({ "name": ["Alice", "Bob", "Charlie", "Alice"], "age": [25, 30, 35, 25] }) # Now the custom method is available directly on the DataFrame filtered_df = df.filter_by_value(column="name", value="Alice") print(filtered_df)
Debug
Known issues
gotchaDirectly registering methods (e.g., with `register_dataframe_method`) can lead to 'monkey-patching' where custom functions directly modify Pandas objects. While convenient, the Pandas community often prefers namespaced accessors (`register_dataframe_accessor`) to prevent potential conflicts and maintain clarity, especially in larger projects or libraries.
fix
Consider using `@pf.register_dataframe_accessor('your_namespace')` to create an accessor class. This namespaces your custom methods under `df.your_namespace.method_name()`.
affects: All versions
breakingWhile `pandas-flavor` aims for backward compatibility with Pandas versions, recent major Pandas updates (e.g., Pandas 3.0) introduce significant breaking changes in Pandas' core behavior (e.g., dedicated string dtype by default, Copy-on-Write). These changes can subtly affect how user-defined `pandas-flavor` methods and accessors operate on data if not accounted for.
fix
Refer to the Pandas official migration guides for major versions (e.g., Pandas 3.0 migration guide) to understand how these core changes might impact your custom methods. It's recommended to upgrade Pandas incrementally (e.g., to 2.3 first, then 3.0) and resolve any deprecation warnings before relying on `pandas-flavor` methods with new Pandas versions.
affects: Pandas 3.0.0+
gotchaRegistering a method or accessor with a name that already exists on a Pandas DataFrame or Series can lead to unexpected behavior or overwrite existing functionality, although `pandas-flavor` may issue a warning in some cases.
fix
Always choose unique and descriptive names for your custom methods and accessors. If there's a potential conflict, consider using an accessor to namespace your methods, reducing the chance of direct name clashes.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pandas_flavor'
The 'pandas-flavor' library is not installed in the current Python environment.
fix
Install the library using pip: `pip install pandas-flavor`
AttributeError: 'DataFrame' object has no attribute 'my_custom_method'
The custom method or accessor, despite being defined with pandas-flavor decorators, has not been properly registered or the module defining it hasn't been imported, preventing Pandas from finding the extension. Alternatively, there might be a typo in the method/accessor name when called.
fix
Ensure the Python module containing the `@pf.register_dataframe_method` or `@pf.register_dataframe_accessor` decorated code is imported in your script (e.g., `import my_flavor_module`). Verify that the method/accessor name used in the call (e.g., `df.my_custom_method()`) exactly matches the name given in the decorator or the method within the accessor class.
AttributeError: 'MyAccessor' object has no attribute 'my_method'
This error occurs when you have registered an accessor using `@pf.register_dataframe_accessor('my_accessor_name')` but are trying to call a method that doesn't exist within the accessor class, or you are calling it incorrectly (e.g., `df.my_accessor_name().my_method()` instead of `df.my_accessor_name.my_method()`).
fix
If the method is part of the accessor, ensure you are calling it correctly through the accessor instance (e.g., `df.my_accessor_name.my_method()`). If the method is not defined, add it to your accessor class. If you intended to register a direct DataFrame method, use `@pf.register_dataframe_method` instead of an accessor.
Upgrade
Version history
0.8.1latest on PyPI · released Nov 22, 2025
Audit
Dependencies
pandasrequiredCore dependency for extending Pandas objects.
pythonrequiredRequires Python 3.10 or newer.
Agent activity
7 hits · last 30 days
node
6
Resources
pandas-flavor — pip install pandas-flavor · libregistry