home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

32 rows where user = 15331990 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: issue_url, reactions, created_at (date), updated_at (date)

issue 17

  • Add drop duplicates 8
  • Xarray equivalent of np.place or df.map(mapping)? 4
  • Binary operations with ds.groupby('time.dayofyear') errors out, but ds.groupby('time.month') works 2
  • roll doesn't handle periodic boundary conditions well 2
  • DataArray transpose inconsistent with Dataset Ellipsis usage 2
  • Add drop_duplicates for dims 2
  • Formatting data array as strings? 2
  • Add strftime() to datetime accessor 1
  • Substituting values based on condition 1
  • [WIP] Feature: Animated 1D plots 1
  • Add "unique()" method, mimicking pandas 1
  • Plot title using loc keyword doesn't override automated title 1
  • Plotting inconsistencies with Cartopy 1
  • Feature request: ds.interp_like() keyword to exclude certain dimensions 1
  • drop keyword in ds.rolling(time=7, drop=True).mean()? 1
  • Wrong hue assignment in scatter plot 1
  • Add unique method 1

user 1

  • ahuang11 · 32 ✖

author_association 1

  • CONTRIBUTOR 32
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1462537234 https://github.com/pydata/xarray/issues/5985#issuecomment-1462537234 https://api.github.com/repos/pydata/xarray/issues/5985 IC_kwDOAMm_X85XLIwS ahuang11 15331990 2023-03-09T18:08:10Z 2023-03-09T18:08:10Z CONTRIBUTOR

Thanks for following up! It's been a while so I don't remember; feel free to disregard what I said.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Formatting data array as strings? 1052753606
969794751 https://github.com/pydata/xarray/issues/5985#issuecomment-969794751 https://api.github.com/repos/pydata/xarray/issues/5985 IC_kwDOAMm_X845zeS_ ahuang11 15331990 2021-11-16T03:27:20Z 2021-11-16T03:27:20Z CONTRIBUTOR

Actually would xr.DataArray.str.format work? e.g. xr.DataArray([0, 1, 2]).str would raise an error right since it's int type?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Formatting data array as strings? 1052753606
840264412 https://github.com/pydata/xarray/pull/5239#issuecomment-840264412 https://api.github.com/repos/pydata/xarray/issues/5239 MDEyOklzc3VlQ29tbWVudDg0MDI2NDQxMg== ahuang11 15331990 2021-05-13T03:25:00Z 2021-05-13T03:25:00Z CONTRIBUTOR

Dont understand this xarray/core/dataarray.py:4605: error: Argument 1 to "isel" of "DataArray" has incompatible type "Dict[str, Any]"; expected "Optional[Mapping[Hashable, Any]]" [arg-type] Found 1 error in 1 file (checked 140 source files)

self.isel(indexes)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop_duplicates for dims 873519048
839934040 https://github.com/pydata/xarray/pull/5239#issuecomment-839934040 https://api.github.com/repos/pydata/xarray/issues/5239 MDEyOklzc3VlQ29tbWVudDgzOTkzNDA0MA== ahuang11 15331990 2021-05-12T16:47:23Z 2021-05-12T16:47:23Z CONTRIBUTOR

Sure.

What's the reasoning for a single dimension?

On Wed, May 12, 2021, 11:34 AM Maximilian Roos @.***> wrote:

@ahuang11 https://github.com/ahuang11 we discussed this on the core team call. People are excited to merge this, and appreciate you bearing with the changes.

I suggested that we narrow this even further to one dimension and merge, so we can benefit from this now and consider additions from there. Would that be OK with you?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pydata/xarray/pull/5239#issuecomment-839925301, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU7FFSS2IQ5QP7BYG4OCWLTNKUXXANCNFSM4353OVNA .

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop_duplicates for dims 873519048
830508669 https://github.com/pydata/xarray/pull/5089#issuecomment-830508669 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgzMDUwODY2OQ== ahuang11 15331990 2021-05-01T03:25:47Z 2021-05-01T03:25:47Z CONTRIBUTOR

I failed to commit properly so see https://github.com/pydata/xarray/pull/5239 where I only do drop duplicates for dims

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
830274959 https://github.com/pydata/xarray/pull/5089#issuecomment-830274959 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgzMDI3NDk1OQ== ahuang11 15331990 2021-04-30T18:16:59Z 2021-04-30T18:17:21Z CONTRIBUTOR

I can take a look this weekend. If narrow, could simply rollback to this commit, make minor adjustments and merge. https://github.com/pydata/xarray/pull/5089/commits/28aa96ab13db72bfa6ad8b156c2c720b49ec9a04

But I personally prefer full so it'd be nice if we could come to a consensus on how to handle it~

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
822094033 https://github.com/pydata/xarray/pull/5089#issuecomment-822094033 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgyMjA5NDAzMw== ahuang11 15331990 2021-04-19T00:19:17Z 2021-04-19T00:19:17Z CONTRIBUTOR

@ahuang11 IIUC, this is only using .stack where it needs to actually stack the array, is that correct? So a list of dims is passed (rather than non-dim coords), then it's not stacking.

I agree with @shoyer that we could do it in a single isel in the basic case. One option is to have a fast path for non-dim coords only, and call isel once with those.

Yes correct. I am not feeling well at the moment so I probably won't get to this today, but feel free to make commits!

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
813782823 https://github.com/pydata/xarray/pull/5089#issuecomment-813782823 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgxMzc4MjgyMw== ahuang11 15331990 2021-04-06T02:48:00Z 2021-04-06T02:48:00Z CONTRIBUTOR

Not sure if there's a more elegant way of implementing this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
813179511 https://github.com/pydata/xarray/pull/5089#issuecomment-813179511 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgxMzE3OTUxMQ== ahuang11 15331990 2021-04-05T04:48:09Z 2021-04-05T04:48:09Z CONTRIBUTOR

Oh I just saw the edits with keeping the dims. I guess that would work.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
813169922 https://github.com/pydata/xarray/pull/5089#issuecomment-813169922 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgxMzE2OTkyMg== ahuang11 15331990 2021-04-05T04:09:26Z 2021-04-05T04:09:26Z CONTRIBUTOR

I prefer drop duplicate values to be under the unique() PR; maybe could be renamed as drop_duplicate_values().

Also I think preserving existing dimensions is more powerful than flattening the dimensions.

On Sun, Apr 4, 2021, 11:01 PM Stephan Hoyer @.***> wrote:

From an API perspective, I think the name drop_duplicates() would be fine. I would guess that handling arbitrary variables in a Dataset would not be any harder than handling only coordinates?

One thing that is a little puzzling to me is how deduplicating across multiple dimensions is handled. It looks like this function preserves existing dimensions, but inserts NA is the arrays would be ragged? This seems a little strange to me. I think it could make more sense to "flatten" all dimensions in the contained variables into a new dimension when dropping duplicates.

This would require specifying the name for the new dimension(s), but perhaps that could work by switching to the de-duplicated variable name? For example, ds.drop_duplicates('valid') on the example in the PR description would result in a "valid" coordinate/dimension of length 3.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pydata/xarray/pull/5089#issuecomment-813168052, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU7FFWCT2NXOR2AYNLGVQDTHEYYFANCNFSM4Z6ZAMUA .

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
813133441 https://github.com/pydata/xarray/pull/5091#issuecomment-813133441 https://api.github.com/repos/pydata/xarray/issues/5091 MDEyOklzc3VlQ29tbWVudDgxMzEzMzQ0MQ== ahuang11 15331990 2021-04-05T01:14:52Z 2021-04-05T01:15:51Z CONTRIBUTOR

What if we added coordinates/dims to it and it returns a stacked dimension if multiple dims? ``` def unique(da): da_stack = da.stack({'tmp_dim': da.dims}) _, index = np.unique(da_stack.values, return_index=True) return da_stack.isel({'tmp_dim': index})

da = xr.DataArray([[[0, 1, 1], [2, 3, 4], [4, 5, 6]], [[7, 8, 9], [10, 11, 12], [13, 14, 15]]], coords={'lat': [0, 1, 2], 'lon': [4, 5, 6], 'time': [7, 8]}, dims=['time', 'lat', 'lon']) unique(da) # would be da.unique() `` Then users can useda.unique().unstack()` if they like.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add unique method 843961481
809814710 https://github.com/pydata/xarray/pull/5089#issuecomment-809814710 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgwOTgxNDcxMA== ahuang11 15331990 2021-03-30T00:27:20Z 2021-04-04T22:26:02Z CONTRIBUTOR

Thanks for the PR @ahuang11 !

I think the method could be really useful. Does anyone else have thoughts?

One important decision is whether this should operate on dimensioned coords or all coords (or even any array?). My guess would be that we could start with dimensioned coords given those are the most likely use case, and we could extent to non-dimensioned coords later.

(here's a glossary as the terms can get confusing: http://xarray.pydata.org/en/stable/terminology.html)

~~Let's start with just dims for now.~~

Okay, since I had some time, I decided to do coords too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
809822634 https://github.com/pydata/xarray/pull/5089#issuecomment-809822634 https://api.github.com/repos/pydata/xarray/issues/5089 MDEyOklzc3VlQ29tbWVudDgwOTgyMjYzNA== ahuang11 15331990 2021-03-30T00:52:18Z 2021-03-30T00:52:18Z CONTRIBUTOR

Not sure how to fix this: ```

xarray/core/dataset.py:7111: error: Keywords must be strings Found 1 error in 1 file (checked 138 source files) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add drop duplicates 842940980
781663427 https://github.com/pydata/xarray/issues/4588#issuecomment-781663427 https://api.github.com/repos/pydata/xarray/issues/4588 MDEyOklzc3VlQ29tbWVudDc4MTY2MzQyNw== ahuang11 15331990 2021-02-18T22:01:59Z 2021-02-18T22:01:59Z CONTRIBUTOR

Yes I want to drop the padding (remove the nans from the beginning)

On Thu, Feb 18, 2021, 3:44 PM Deepak Cherian notifications@github.com wrote:

Do you want to avoid the padding?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pydata/xarray/issues/4588#issuecomment-781654195, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU7FFVBUJGELDFGWQ6TARDS7WC23ANCNFSM4TX2CAEQ .

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  drop keyword in ds.rolling(time=7, drop=True).mean()? 744274576
753477348 https://github.com/pydata/xarray/issues/4647#issuecomment-753477348 https://api.github.com/repos/pydata/xarray/issues/4647 MDEyOklzc3VlQ29tbWVudDc1MzQ3NzM0OA== ahuang11 15331990 2021-01-02T14:01:49Z 2021-01-02T14:01:49Z CONTRIBUTOR

Sure.

On Sat, Jan 2, 2021, 6:38 AM Daniel Mesejo-León notifications@github.com wrote:

Hey! Can I work on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pydata/xarray/issues/4647#issuecomment-753468760, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU7FFVUS2TTAA6MRGX5G73SX4HSRANCNFSM4UMKLBWQ .

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray transpose inconsistent with Dataset Ellipsis usage 756415834
749323873 https://github.com/pydata/xarray/issues/4641#issuecomment-749323873 https://api.github.com/repos/pydata/xarray/issues/4641 MDEyOklzc3VlQ29tbWVudDc0OTMyMzg3Mw== ahuang11 15331990 2020-12-22T03:55:33Z 2020-12-22T03:55:33Z CONTRIBUTOR

Maybe a simple fix would be to replace np.unique with pd.unique since it's ordered? ``` Hash table-based unique. Uniques are returned in order of appearance. This does NOT sort.

Significantly faster than numpy.unique. Includes NA values. ```

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.unique.html

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Wrong hue assignment in scatter plot 755105132
738187109 https://github.com/pydata/xarray/issues/4647#issuecomment-738187109 https://api.github.com/repos/pydata/xarray/issues/4647 MDEyOklzc3VlQ29tbWVudDczODE4NzEwOQ== ahuang11 15331990 2020-12-03T18:10:44Z 2020-12-03T18:10:44Z CONTRIBUTOR

ds.transpose('not_existing_dim', 'lat', 'lon', 'time', ...)

IMO this should raise an error too

I actually like it handling non_existing_dims automatically; maybe could be keyword though: ds.transpose('not_existing_dim', 'lat', 'lon', 'time', ..., errors='ignore')

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray transpose inconsistent with Dataset Ellipsis usage 756415834
671104032 https://github.com/pydata/xarray/issues/3169#issuecomment-671104032 https://api.github.com/repos/pydata/xarray/issues/3169 MDEyOklzc3VlQ29tbWVudDY3MTEwNDAzMg== ahuang11 15331990 2020-08-09T21:37:20Z 2020-08-09T21:37:20Z CONTRIBUTOR

I think this is fixed in the latest master.

``` import xarray as xr import numpy as np import cartopy.crs as ccrs

da = xr.tutorial.open_dataset('air_temperature')['air']

p = da.isel(time=[0, 1]).plot( transform=ccrs.PlateCarree(), col='time', subplot_kws={'projection': ccrs.Orthographic(-80, 35)} )

for ax in p.axes.flat: ax.coastlines() ax.gridlines() ```

p = da.isel(time=0).plot( transform=ccrs.PlateCarree(), subplot_kws={'projection': ccrs.Orthographic(-80, 35)} )

However if you try iterating over the axes, it will crash because p is quadmesh type not a facetgrid type so I was wondering whether it'd be good to have an keyword like force_facetgrid_type=True which uses the FacetGrid class to plot a single map so that the user can keep the same code for single axes and facet axes? ``` p = da.isel(time=0).plot( transform=ccrs.PlateCarree(), subplot_kws={'projection': ccrs.Orthographic(-80, 35)} )

for ax in p.axes.flat: ax.coastlines() ax.gridlines() ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Plotting inconsistencies with Cartopy 474463902
671101989 https://github.com/pydata/xarray/issues/2568#issuecomment-671101989 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDY3MTEwMTk4OQ== ahuang11 15331990 2020-08-09T21:15:41Z 2020-08-09T21:15:41Z CONTRIBUTOR

If I were to make a PR, where would this method reside? Would it be under dataset.py and dataarray.py? Also, would I simply call np.select inside the method, and if so, how would I add support for dask?

My minimal example atm: ``` import xarray as xr import numpy as np import hvplot.xarray

ds = xr.tutorial.open_dataset('air_temperature').isel(time=0)

ds['air_cats'] = ( ('lat', 'lon'), np.select([ds['air'].values >= 273.15, ds['air'].values < 273.15], ['above freezing', 'below freezing']) ) ds.hvplot('lon', 'lat', hover_cols=['air_cats']) ```

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
629384825 https://github.com/pydata/xarray/issues/4066#issuecomment-629384825 https://api.github.com/repos/pydata/xarray/issues/4066 MDEyOklzc3VlQ29tbWVudDYyOTM4NDgyNQ== ahuang11 15331990 2020-05-15T17:28:09Z 2020-05-15T17:28:09Z CONTRIBUTOR

Neat solution! Thanks!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Feature request: ds.interp_like() keyword to exclude certain dimensions 619089111
599133152 https://github.com/pydata/xarray/issues/2568#issuecomment-599133152 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDU5OTEzMzE1Mg== ahuang11 15331990 2020-03-14T20:48:52Z 2020-03-14T20:48:52Z CONTRIBUTOR

No, not from me at least.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
495069997 https://github.com/pydata/xarray/pull/2144#issuecomment-495069997 https://api.github.com/repos/pydata/xarray/issues/2144 MDEyOklzc3VlQ29tbWVudDQ5NTA2OTk5Nw== ahuang11 15331990 2019-05-23T05:13:46Z 2019-05-23T05:13:46Z CONTRIBUTOR

Would also like to see this move forward and would be happy to help if needed.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add strftime() to datetime accessor 323823894
494914857 https://github.com/pydata/xarray/issues/2981#issuecomment-494914857 https://api.github.com/repos/pydata/xarray/issues/2981 MDEyOklzc3VlQ29tbWVudDQ5NDkxNDg1Nw== ahuang11 15331990 2019-05-22T18:34:03Z 2019-05-22T18:34:03Z CONTRIBUTOR

Cool; that's good to know that I can set a title on the top left and top right side together. Thanks.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Plot title using loc keyword doesn't override automated title 447268579
489293638 https://github.com/pydata/xarray/pull/2729#issuecomment-489293638 https://api.github.com/repos/pydata/xarray/issues/2729 MDEyOklzc3VlQ29tbWVudDQ4OTI5MzYzOA== ahuang11 15331990 2019-05-04T04:46:34Z 2019-05-04T04:47:30Z CONTRIBUTOR

This looks awesome; it would be really nice to have built-in xarray animation support!

I'm personally more excited about 2D animations and am happy to implement that once all the common infrastructure is in.

Also wanted to point out while that's progressing along, hvplot supports 2D animations. https://hvplot.pyviz.org/ ``` import xarray as xr import hvplot.xarray import holoviews as hv hv.extension('matplotlib')

ds = xr.tutorial.open_dataset('air_temperature').isel(time=slice(0, 15)) hmap = ds.hvplot('lon', 'lat', dynamic=False).opts(fig_size=300, clim=(230, 300)) hv.save(hmap, 'anim.html', fmt='scrubber')

---

from IPython.core.display import display, HTML display(HTML('anim.html')) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  [WIP] Feature: Animated 1D plots 404945709
469477745 https://github.com/pydata/xarray/issues/2795#issuecomment-469477745 https://api.github.com/repos/pydata/xarray/issues/2795 MDEyOklzc3VlQ29tbWVudDQ2OTQ3Nzc0NQ== ahuang11 15331990 2019-03-05T00:01:58Z 2019-03-05T00:01:58Z CONTRIBUTOR

Right, it would return a 1D numpy or dask array.

I suppose I'm used to simply typing pd.Series().unique() rather than np.unique(pd.Series()).

I use it in for loops primarily. for season in da['time.season'].unique(): vs for season in np.unique(da['time.season'].data):

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add "unique()" method, mimicking pandas 415774106
457797022 https://github.com/pydata/xarray/issues/2711#issuecomment-457797022 https://api.github.com/repos/pydata/xarray/issues/2711 MDEyOklzc3VlQ29tbWVudDQ1Nzc5NzAyMg== ahuang11 15331990 2019-01-26T03:22:07Z 2019-01-26T03:22:07Z CONTRIBUTOR

Cool, didn't know the function had different kwargs from the method. Thanks!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Substituting values based on condition 403350812
441344567 https://github.com/pydata/xarray/issues/2568#issuecomment-441344567 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTM0NDU2Nw== ahuang11 15331990 2018-11-24T05:17:09Z 2018-11-24T05:25:45Z CONTRIBUTOR

Thanks for the quick replies! Is there interest in making this a built-in function? If so, I can help contribute a PR.

Also wondering about a way to wrap logic to that mapping.

Like below 0, replace with -1, between 0 and 10, replace with 5, and above 10, replace with 15 which is possible with three np.place statements I think, but have to think in backwards logic with ds.where().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441342986 https://github.com/pydata/xarray/issues/2568#issuecomment-441342986 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTM0Mjk4Ng== ahuang11 15331990 2018-11-24T04:34:17Z 2018-11-24T04:34:17Z CONTRIBUTOR

I guess I'm thinking about more complex cases such as changing 0 -> 50, 1 -> 29, 2 -> 10

ds = xr.Dataset({'test': [0, 1, 2]}) ds.where((ds != 1) & (ds != 2), 50)

Thoughts on simplifying this?

{
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
411275886 https://github.com/pydata/xarray/issues/1875#issuecomment-411275886 https://api.github.com/repos/pydata/xarray/issues/1875 MDEyOklzc3VlQ29tbWVudDQxMTI3NTg4Ng== ahuang11 15331990 2018-08-08T03:51:54Z 2018-08-08T03:51:54Z CONTRIBUTOR

Option 2 sounds good; I'll try putting together a pull request sometime, hopefully within a week!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  roll doesn't handle periodic boundary conditions well 293345254
411219752 https://github.com/pydata/xarray/issues/1875#issuecomment-411219752 https://api.github.com/repos/pydata/xarray/issues/1875 MDEyOklzc3VlQ29tbWVudDQxMTIxOTc1Mg== ahuang11 15331990 2018-08-07T22:11:42Z 2018-08-07T22:11:42Z CONTRIBUTOR

Just wanted to bump this! Would make my hack neater to interpolate across the prime meridian.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  roll doesn't handle periodic boundary conditions well 293345254
325163311 https://github.com/pydata/xarray/issues/1527#issuecomment-325163311 https://api.github.com/repos/pydata/xarray/issues/1527 MDEyOklzc3VlQ29tbWVudDMyNTE2MzMxMQ== ahuang11 15331990 2017-08-26T21:38:35Z 2017-08-26T21:38:35Z CONTRIBUTOR

I don't know if you tried this yet, but if you changed the length to 365 and keep it with non-leap year, it still errors out so I guess the root issue is with how time.dayofyear uses 366 days?

``` import xarray as xr import numpy as np import pandas as pd

d1 = xr.DataArray(np.zeros(12000), [('time', pd.date_range('2004-01-01', freq='D', periods=12000))]) d2 = xr.DataArray(np.zeros((365, 10)), {'time': pd.date_range('1979-01-01', freq='D', periods=365), 'x': ('x', np.arange(10))}, dims=['time', 'x'])

d1.groupby('time.month') * d2.groupby('time.month').mean('time') print('this works')

no work

d1.groupby('time.dayofyear') * d2.groupby('time.dayofyear').mean('time') print('this doesn\'t work') ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Binary operations with ds.groupby('time.dayofyear') errors out, but ds.groupby('time.month') works 253107677
325149596 https://github.com/pydata/xarray/issues/1527#issuecomment-325149596 https://api.github.com/repos/pydata/xarray/issues/1527 MDEyOklzc3VlQ29tbWVudDMyNTE0OTU5Ng== ahuang11 15331990 2017-08-26T17:28:28Z 2017-08-26T17:32:00Z CONTRIBUTOR

Thanks for your quick response! From conda list xarray 0.9.6 <pip>

If you swap the length it errors out. ``` import xarray as xr import numpy as np import pandas as pd

d1 = xr.DataArray(np.zeros(12000), [('time', pd.date_range('1979-01-01', freq='D', periods=12000))]) d2 = xr.DataArray(np.zeros((366, 10)), {'time': pd.date_range('1979-01-01', freq='D', periods=366), 'x': ('x', np.arange(10))}, dims=['time', 'x'])

d1.groupby('time.month') - d2.groupby('time.month').mean('time') print('this works')

no work

d1.groupby('time.dayofyear') - d2.groupby('time.dayofyear').mean('time') print('this doesn\'t work') ```

``` <xarray.DataArray (time: 12000, x: 10)> array([[ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0., ..., 0., 0., 0.], ..., [ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0., ..., 0., 0., 0.]]) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 * time (time) datetime64[ns] 1979-01-01 1979-01-02 1979-01-03 ... month (time) int64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... this works


KeyError Traceback (most recent call last) <ipython-input-24-4c92f88d0a14> in <module>() 10 11 # no work ---> 12 d1.groupby('time.dayofyear') - d2.groupby('time.dayofyear').mean('time') 13 print('this doesn\'t work')

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/groupby.py in func(self, other) 316 g = f if not reflexive else lambda x, y: f(y, x) 317 applied = self._yield_binary_applied(g, other) --> 318 combined = self._combine(applied) 319 return combined 320 return func

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/groupby.py in _combine(self, applied, shortcut) 532 combined = self._concat_shortcut(applied, dim, positions) 533 else: --> 534 combined = concat(applied, dim) 535 combined = _maybe_reorder(combined, dim, positions) 536

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in concat(objs, dim, data_vars, coords, compat, positions, indexers, mode, concat_over) 118 raise TypeError('can only concatenate xarray Dataset and DataArray ' 119 'objects, got %s' % type(first_obj)) --> 120 return f(objs, dim, data_vars, coords, compat, positions) 121 122

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in _dataarray_concat(arrays, dim, data_vars, coords, compat, positions) 304 305 ds = _dataset_concat(datasets, dim, data_vars, coords, compat, --> 306 positions) 307 return arrays[0]._from_temp_dataset(ds, name) 308

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in _dataset_concat(datasets, dim, data_vars, coords, compat, positions) 210 datasets = align(*datasets, join='outer', copy=False, exclude=[dim]) 211 --> 212 concat_over = _calc_concat_over(datasets, dim, data_vars, coords) 213 214 def insert_result_variable(k, v):

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in _calc_concat_over(datasets, dim, data_vars, coords) 190 if dim in v.dims) 191 concat_over.update(process_subset_opt(data_vars, 'data_vars')) --> 192 concat_over.update(process_subset_opt(coords, 'coords')) 193 if dim in datasets[0]: 194 concat_over.add(dim)

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in process_subset_opt(opt, subset) 165 for ds in datasets[1:]) 166 # all nonindexes that are not the same in each dataset --> 167 concat_new = set(k for k in getattr(datasets[0], subset) 168 if k not in concat_over and differs(k)) 169 elif opt == 'all':

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in <genexpr>(.0) 166 # all nonindexes that are not the same in each dataset 167 concat_new = set(k for k in getattr(datasets[0], subset) --> 168 if k not in concat_over and differs(k)) 169 elif opt == 'all': 170 concat_new = (set(getattr(datasets[0], subset)) -

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in differs(vname) 163 v = datasets[0].variables[vname] 164 return any(not ds.variables[vname].equals(v) --> 165 for ds in datasets[1:]) 166 # all nonindexes that are not the same in each dataset 167 concat_new = set(k for k in getattr(datasets[0], subset)

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/combine.py in <genexpr>(.0) 163 v = datasets[0].variables[vname] 164 return any(not ds.variables[vname].equals(v) --> 165 for ds in datasets[1:]) 166 # all nonindexes that are not the same in each dataset 167 concat_new = set(k for k in getattr(datasets[0], subset)

/data/keeling/a/ahuang11/anaconda3/lib/python3.6/site-packages/xarray/core/utils.py in getitem(self, key) 288 289 def getitem(self, key): --> 290 return self.mapping[key] 291 292 def iter(self):

KeyError: 'x' ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Binary operations with ds.groupby('time.dayofyear') errors out, but ds.groupby('time.month') works 253107677

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 1119.952ms · About: xarray-datasette