Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: set accessor for Series (WIP) #21547

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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