Skip to content

Commit 1953aee

Browse files
authored
Merge pull request #10 from Zsailer/readme
Installation, contributing, architecture sections to readme.
2 parents 21c9cb5 + 23b91a3 commit 1953aee

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Pandas Flavor
22
**The easy way to write your own flavor of Pandas**
33

4-
Pandas added an new (simple) API to register accessors with Pandas objects.
5-
This package does two things:
6-
1. adds support for registering methods as well.
7-
2. makes each of these functions backwards compatible with older versions of Pandas.
4+
Pandas 0.23 added a (simple) API for registering accessors with Pandas objects.
5+
6+
Pandas-flavor extends Pandas' extension API by:
7+
1. adding support for registering methods as well.
8+
2. making each of these functions backwards compatible with older versions of Pandas.
89

910
***What does this mean?***
1011

@@ -119,3 +120,34 @@ df.row_by_value('x', 10)
119120
- **register_dataframe_accessor**: register an accessor (and it's methods) with a pandas DataFrame.
120121
- **register_series_method**: register a methods directly with a pandas Series.
121122
- **register_series_accessor**: register an accessor (and it's methods) with a pandas Series.
123+
124+
## Installation
125+
126+
You can install using **pip**:
127+
```
128+
pip install pandas_flavor
129+
```
130+
or conda (thanks @ericmjl)!
131+
```
132+
conda install -c conda-forge pandas-flavor
133+
```
134+
135+
## Contributing
136+
137+
Pull requests are always welcome! If you find a bug, don't hestitate to open an issue or submit a PR. If you're not sure how to do that, check out this [simple guide](https://github.com/Zsailer/guide-to-working-as-team-on-github).
138+
139+
If you have a feature request, please open an issue or submit a PR!
140+
141+
## TL;DR
142+
143+
Pandas 0.23 introduced a simpler API for [extending Pandas](https://pandas.pydata.org/pandas-docs/stable/development/extending.html#extending-pandas). This API provided two key decorators, `register_dataframe_accessor` and `register_series_accessor`, that enable users to register **accessors** with Pandas DataFrames and Series.
144+
145+
Pandas Flavor originated as a library to backport these decorators to older versions of Pandas (<0.23). While doing the backporting, it became clear that registering **methods** directly to Pandas objects might be a desired feature as well.[*](#footnote)
146+
147+
<a name="footnote">*</a>*It is likely that Pandas deliberately chose not implement to this feature. If everyone starts monkeypatching DataFrames with their custom methods, it could lead to confusion in the Pandas community. The preferred Pandas approach is to namespace your methods by registering an accessor that contains your custom methods.*
148+
149+
**So how does method registration work?**
150+
151+
When you register a method, Pandas flavor actually creates and registers a (this is subtle, but important) **custom accessor class that mimics** the behavior of a method by:
152+
1. inheriting the docstring of your function
153+
2. overriding the `__call__` method to call your function.

0 commit comments

Comments
 (0)