Skip to content

Commit

Permalink
ENH: set accessor (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Jun 19, 2018
1 parent 5fbb683 commit a3563da
Show file tree
Hide file tree
Showing 3 changed files with 620 additions and 1 deletion.
30 changes: 30 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,36 @@ strings and apply several methods to it. These can be accessed like
Series.dt
Index.str

Set handling
~~~~~~~~~~~~~~~
``Series.set`` can be used to access the values of the series as
sets and apply several methods to it. These can be accessed like
``Series.set.<function/property>``.

.. autosummary::
:toctree: generated/
:template: autosummary/accessor_method.rst

Series.set.union
Series.set.intersect
Series.set.xor
Series.set.diff
Series.set.len

..
The following is needed to ensure the generated pages are created with the
correct template (otherwise they would be created in the Series/Index class page)
..
.. autosummary::
:toctree: generated/
:template: autosummary/accessor.rst
Series.str
Series.cat
Series.dt
Series.set

.. _api.categorical:

Categorical
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from pandas._libs import index as libindex, tslib as libts, lib, iNaT
from pandas.core.config import get_option
from pandas.core.strings import StringMethods
from pandas.core.sets import SetMethods

import pandas.plotting._core as gfx

Expand Down Expand Up @@ -158,7 +159,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
Copy input data
"""
_metadata = ['name']
_accessors = set(['dt', 'cat', 'str'])
_accessors = set(['dt', 'cat', 'str', 'set'])
_deprecations = generic.NDFrame._deprecations | frozenset(
['asobject', 'sortlevel', 'reshape', 'get_value', 'set_value',
'from_csv', 'valid'])
Expand Down Expand Up @@ -3992,6 +3993,7 @@ def to_period(self, freq=None, copy=True):
# Accessor Methods
# ----------------------------------------------------------------------
str = CachedAccessor("str", StringMethods)
set = CachedAccessor("set", SetMethods)
dt = CachedAccessor("dt", CombinedDatetimelikeProperties)
cat = CachedAccessor("cat", CategoricalAccessor)
plot = CachedAccessor("plot", gfx.SeriesPlotMethods)
Expand Down
Loading

0 comments on commit a3563da

Please sign in to comment.