Skip to content

Commit

Permalink
str accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0L committed May 27, 2019
1 parent 7edf2e2 commit 22621a2
Show file tree
Hide file tree
Showing 7 changed files with 1,635 additions and 4 deletions.
10 changes: 10 additions & 0 deletions doc/api.rst
Expand Up @@ -324,6 +324,7 @@ Computation
DataArray.quantile
DataArray.differentiate
DataArray.integrate
DataArray.str

**Aggregation**:
:py:attr:`~DataArray.all`
Expand Down Expand Up @@ -557,6 +558,15 @@ Resample objects also implement the GroupBy interface
core.resample.DatasetResample.nearest
core.resample.DatasetResample.pad

Accessors
=========

.. autosummary::
:toctree: generated/

core.accessor_dt.DatetimeAccessor
core.accessor_str.StringAccessor

Custom Indexes
==============
.. autosummary::
Expand Down
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Expand Up @@ -42,6 +42,8 @@ Enhancements
helpful for avoiding file-lock errors when trying to write to files opened
using ``open_dataset()`` or ``open_dataarray()``. (:issue:`2887`)
By `Dan Nowacki <https://github.com/dnowacki-usgs>`_.
- Add ``.str`` accessor to DataArrays for string related manipulations.
By `0x0L <https://github.com/0x0L>`_.

Bug fixes
~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/accessors.py → xarray/core/accessor_dt.py
Expand Up @@ -133,13 +133,13 @@ class DatetimeAccessor:
"""

def __init__(self, xarray_obj):
if not _contains_datetime_like_objects(xarray_obj):
def __init__(self, obj):
if not _contains_datetime_like_objects(obj):
raise TypeError("'dt' accessor only available for "
"DataArray with datetime64 timedelta64 dtype or "
"for arrays containing cftime datetime "
"objects.")
self._obj = xarray_obj
self._obj = obj

def _tslib_field_accessor(name, docstring=None, dtype=None):
def f(self, dtype=dtype):
Expand Down

0 comments on commit 22621a2

Please sign in to comment.