Skip to content

Commit 4fe9b72

Browse files
committed
str accessor
1 parent 74e5ff6 commit 4fe9b72

File tree

7 files changed

+1635
-4
lines changed

7 files changed

+1635
-4
lines changed

doc/api.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ Computation
324324
DataArray.quantile
325325
DataArray.differentiate
326326
DataArray.integrate
327+
DataArray.str
327328

328329
**Aggregation**:
329330
:py:attr:`~DataArray.all`
@@ -557,6 +558,15 @@ Resample objects also implement the GroupBy interface
557558
core.resample.DatasetResample.nearest
558559
core.resample.DatasetResample.pad
559560

561+
Accessors
562+
=========
563+
564+
.. autosummary::
565+
:toctree: generated/
566+
567+
core.accessor_dt.DatetimeAccessor
568+
core.accessor_str.StringAccessor
569+
560570
Custom Indexes
561571
==============
562572
.. autosummary::

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Enhancements
4949
- Like :py:class:`pandas.DatetimeIndex`, :py:class:`CFTimeIndex` now supports a
5050
:py:meth:`~xarray.CFTimeIndex.strftime` method to return an index of string
5151
formatted datetimes. By `Alan Brammer <https://github.com/abrammer>`_.
52+
- Add ``.str`` accessor to DataArrays for string related manipulations.
53+
By `0x0L <https://github.com/0x0L>`_.
5254

5355
Bug fixes
5456
~~~~~~~~~

xarray/core/accessors.py renamed to xarray/core/accessor_dt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ class DatetimeAccessor:
165165
166166
"""
167167

168-
def __init__(self, xarray_obj):
169-
if not _contains_datetime_like_objects(xarray_obj):
168+
def __init__(self, obj):
169+
if not _contains_datetime_like_objects(obj):
170170
raise TypeError("'dt' accessor only available for "
171171
"DataArray with datetime64 timedelta64 dtype or "
172172
"for arrays containing cftime datetime "
173173
"objects.")
174-
self._obj = xarray_obj
174+
self._obj = obj
175175

176176
def _tslib_field_accessor(name, docstring=None, dtype=None):
177177
def f(self, dtype=dtype):

0 commit comments

Comments
 (0)