Skip to content

Commit a3563da

Browse files
committed
ENH: set accessor (WIP)
1 parent 5fbb683 commit a3563da

File tree

3 files changed

+620
-1
lines changed

3 files changed

+620
-1
lines changed

doc/source/api.rst

+30
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,36 @@ strings and apply several methods to it. These can be accessed like
686686
Series.dt
687687
Index.str
688688

689+
Set handling
690+
~~~~~~~~~~~~~~~
691+
``Series.set`` can be used to access the values of the series as
692+
sets and apply several methods to it. These can be accessed like
693+
``Series.set.<function/property>``.
694+
695+
.. autosummary::
696+
:toctree: generated/
697+
:template: autosummary/accessor_method.rst
698+
699+
Series.set.union
700+
Series.set.intersect
701+
Series.set.xor
702+
Series.set.diff
703+
Series.set.len
704+
705+
..
706+
The following is needed to ensure the generated pages are created with the
707+
correct template (otherwise they would be created in the Series/Index class page)
708+
709+
..
710+
.. autosummary::
711+
:toctree: generated/
712+
:template: autosummary/accessor.rst
713+
714+
Series.str
715+
Series.cat
716+
Series.dt
717+
Series.set
718+
689719
.. _api.categorical:
690720

691721
Categorical

pandas/core/series.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
from pandas._libs import index as libindex, tslib as libts, lib, iNaT
7878
from pandas.core.config import get_option
7979
from pandas.core.strings import StringMethods
80+
from pandas.core.sets import SetMethods
8081

8182
import pandas.plotting._core as gfx
8283

@@ -158,7 +159,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
158159
Copy input data
159160
"""
160161
_metadata = ['name']
161-
_accessors = set(['dt', 'cat', 'str'])
162+
_accessors = set(['dt', 'cat', 'str', 'set'])
162163
_deprecations = generic.NDFrame._deprecations | frozenset(
163164
['asobject', 'sortlevel', 'reshape', 'get_value', 'set_value',
164165
'from_csv', 'valid'])
@@ -3992,6 +3993,7 @@ def to_period(self, freq=None, copy=True):
39923993
# Accessor Methods
39933994
# ----------------------------------------------------------------------
39943995
str = CachedAccessor("str", StringMethods)
3996+
set = CachedAccessor("set", SetMethods)
39953997
dt = CachedAccessor("dt", CombinedDatetimelikeProperties)
39963998
cat = CachedAccessor("cat", CategoricalAccessor)
39973999
plot = CachedAccessor("plot", gfx.SeriesPlotMethods)

0 commit comments

Comments
 (0)