-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ENH: str accessor #2991
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: str accessor #2991
Conversation
0d8f4e9
to
d7dc294
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs tests, but looks like a great start!
This is getting a little long, so maybe it would make sense to split this into another module, e.g., xarray/core/str_accessor.py
? The existing xarray/core/accessors.py
could be renamed to xarray/core/dt_accessor.py
.
xarray/core/accessors.py
Outdated
f = lambda x: x[s] | ||
return self._apply(f) | ||
|
||
def slice_replace(self, start=None, stop=None, repl=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just be repl=''
?
xarray/core/accessors.py
Outdated
|
||
def _apply(self, f): | ||
# TODO handling of na values ? | ||
return apply_ufunc(np.vectorize(f), self._obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add dask='parallelized
to add dask support? I'm pretty sure that should "just work" with these functions.
@shoyer |
You will need to reference the underlying class, e.g., |
@0x0L did you copy any of this code or tests from pandas? If so, that's totally fine, but we should include the original pandas copyright notice. See what we did in |
@shoyer it should be all good now |
thanks @0x0L ! |
* master: (31 commits) Add quantile method to GroupBy (pydata#2828) rolling_exp (nee ewm) (pydata#2650) Ensure explicitly indexed arrays are preserved (pydata#3027) add back dask-dev tests (pydata#3025) ENH: keepdims=True for xarray reductions (pydata#3033) Revert cmap fix (pydata#3038) Add "errors" keyword argument to drop() and drop_dims() (pydata#2994) (pydata#3028) More consistency checks (pydata#2859) Check types in travis (pydata#3024) Update issue templates (pydata#3019) Add pytest markers to avoid warnings (pydata#3023) Feature/merge errormsg (pydata#2971) More support for missing_value. (pydata#2973) Use flake8 rather than pycodestyle (pydata#3010) Pandas labels deprecation (pydata#3016) Pytest capture uses match, not message (pydata#3011) dask-dev tests to allowed failures in travis (pydata#3014) Fix 'to_masked_array' computing dask arrays twice (pydata#3006) str accessor (pydata#2991) fix safe_cast_to_index (pydata#3001) ...
Hello,
Some of the pandas str functionalities. Instead of wrapping pandas internal as in #2983 I copy/pasted the code since it's simple and tiny.
Currently it's a bit more restrictive than pandas since it expects all elements to be string like.
whats-new.rst
for all changes andapi.rst
for new API