id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 415774106,MDU6SXNzdWU0MTU3NzQxMDY=,2795,"Add ""unique()"" method, mimicking pandas",15331990,open,0,,,6,2019-02-28T18:58:15Z,2024-01-08T17:31:30Z,,CONTRIBUTOR,,,,"Would it be good to add a unique() method that mimics pandas? ``` import pandas as pd import xarray as xr pd.Series([0, 1, 1, 2]).unique() xr.DataArray([0, 1, 1, 2]).unique() # not implemented ``` Output: ``` array([0, 1, 2]) AttributeError: 'DataArray' object has no attribute 'unique' ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2795/reactions"", ""total_count"": 10, ""+1"": 10, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 1052753606,I_kwDOAMm_X84-v77G,5985,Formatting data array as strings?,15331990,open,0,,,7,2021-11-13T19:29:02Z,2023-03-17T13:10:06Z,,CONTRIBUTOR,,,,"https://github.com/pydata/xarray/discussions/5865#discussioncomment-1636647 I wonder if it's possible to implement a built-in function like: `da.str.format(""%.2f"")` or `xr.string_format(da, ""%.2f)` To wrap: ``` import xarray as xr da = xr.DataArray([5., 6., 7.]) das = xr.DataArray(""%.2f"") das.str % da array(['5.00', '6.00', '7.00'], dtype=' 1: raise ValueError(f'Found overlapping values in datasets {overlap}') ds.to_zarr('test_air.zarr', append_dim='time') ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4958/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 809708107,MDU6SXNzdWU4MDk3MDgxMDc=,4917,Comparing against datetime.datetime and pd.Timestamp,15331990,open,0,,,1,2021-02-16T22:54:39Z,2021-03-25T22:18:08Z,,CONTRIBUTOR,,,,"Not sure if exactly bug and what performance implications there are but it'd be more user friendly if supported: **1.) comparing against datetime** ```python import datetime import pandas as pd import xarray as xr ds = xr.Dataset(coords={'int': [0, 1, 2]}) ds['data'] = ('int', [0, 5, 6]) ds.coords['time'] = ('int', pd.date_range('2017-02-01', '2017-02-03')) ds = ds.where(ds['time'] > datetime.datetime(2017, 2, 2)) ds ``` `TypeError: '>' not supported between instances of 'int' and 'datetime.datetime'` **2.) pd.Timestamp** ```python import datetime import pandas as pd import xarray as xr ds = xr.Dataset(coords={'int': [0, 1, 2]}) ds['data'] = ('int', [0, 5, 6]) ds.coords['time'] = ('int', pd.date_range('2017-02-01', '2017-02-03')) ds = ds.where(ds['time'] > pd.to_datetime('2017-02-02')) ds ``` This works though when converting to np.datetime64 ```python import datetime import pandas as pd import xarray as xr ds = xr.Dataset(coords={'int': [0, 1, 2]}) ds['data'] = ('int', [0, 5, 6]) ds.coords['time'] = ('int', pd.date_range('2017-02-01', '2017-02-03')) ds = ds.where(ds['time'] > pd.to_datetime(['2017-02-02']).values) ds ``` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4917/reactions"", ""total_count"": 3, ""+1"": 3, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 743165216,MDU6SXNzdWU3NDMxNjUyMTY=,4587,ffill with datetime64 errors,15331990,open,0,,,1,2020-11-15T02:38:39Z,2020-11-15T14:23:19Z,,CONTRIBUTOR,,,,"``` import xarray as xr import pandas as pd xr.DataArray(pd.date_range('2020-01-01', '2020-02-01').tolist() + [pd.NaT]).ffill('dim_0') ``` ``` array(['2020-01-01T00:00:00.000000000', '2020-01-02T00:00:00.000000000', '2020-01-03T00:00:00.000000000', '2020-01-04T00:00:00.000000000', '2020-01-05T00:00:00.000000000', '2020-01-06T00:00:00.000000000', '2020-01-07T00:00:00.000000000', '2020-01-08T00:00:00.000000000', '2020-01-09T00:00:00.000000000', '2020-01-10T00:00:00.000000000', '2020-01-11T00:00:00.000000000', '2020-01-12T00:00:00.000000000', '2020-01-13T00:00:00.000000000', '2020-01-14T00:00:00.000000000', '2020-01-15T00:00:00.000000000', '2020-01-16T00:00:00.000000000', '2020-01-17T00:00:00.000000000', '2020-01-18T00:00:00.000000000', '2020-01-19T00:00:00.000000000', '2020-01-20T00:00:00.000000000', '2020-01-21T00:00:00.000000000', '2020-01-22T00:00:00.000000000', '2020-01-23T00:00:00.000000000', '2020-01-24T00:00:00.000000000', '2020-01-25T00:00:00.000000000', '2020-01-26T00:00:00.000000000', '2020-01-27T00:00:00.000000000', '2020-01-28T00:00:00.000000000', '2020-01-29T00:00:00.000000000', '2020-01-30T00:00:00.000000000', '2020-01-31T00:00:00.000000000', '2020-02-01T00:00:00.000000000', 'NaT'], dtype='datetime64[ns]') Dimensions without coordinates: dim_0 ``` ``` ~/anaconda3/envs/py3/lib/python3.7/site-packages/xarray/core/computation.py in apply_variable_ufunc(func, signature, exclude_dims, dask, output_dtypes, vectorize, keep_attrs, dask_gufunc_kwargs, *args) 698 ) 699 --> 700 result_data = func(*input_data) 701 702 if signature.num_outputs == 1: ~/anaconda3/envs/py3/lib/python3.7/site-packages/bottleneck/slow/nonreduce_axis.py in push(a, n, axis) 49 elif ndim == 0: 50 return y ---> 51 fidx = ~np.isnan(y) 52 recent = np.empty(y.shape[:-1]) 53 count = np.empty(y.shape[:-1]) TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4587/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue