Skip to content

Commit b46611f

Browse files
committed
ENH: set accessor (WIP)
1 parent 0c65c57 commit b46611f

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
@@ -76,6 +76,7 @@
7676
from pandas._libs import index as libindex, tslib as libts, lib, iNaT
7777
from pandas.core.config import get_option
7878
from pandas.core.strings import StringMethods
79+
from pandas.core.sets import SetMethods
7980

8081
import pandas.plotting._core as gfx
8182

@@ -157,7 +158,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
157158
Copy input data
158159
"""
159160
_metadata = ['name']
160-
_accessors = set(['dt', 'cat', 'str'])
161+
_accessors = set(['dt', 'cat', 'str', 'set'])
161162
_deprecations = generic.NDFrame._deprecations | frozenset(
162163
['asobject', 'sortlevel', 'reshape', 'get_value', 'set_value',
163164
'from_csv', 'valid'])
@@ -3970,6 +3971,7 @@ def to_period(self, freq=None, copy=True):
39703971
# Accessor Methods
39713972
# ----------------------------------------------------------------------
39723973
str = CachedAccessor("str", StringMethods)
3974+
set = CachedAccessor("set", SetMethods)
39733975
dt = CachedAccessor("dt", CombinedDatetimelikeProperties)
39743976
cat = CachedAccessor("cat", CategoricalAccessor)
39753977
plot = CachedAccessor("plot", gfx.SeriesPlotMethods)

0 commit comments

Comments
 (0)