home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 932229595

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/2511#issuecomment-932229595 https://api.github.com/repos/pydata/xarray/issues/2511 932229595 IC_kwDOAMm_X843kLHb 16700639 2021-10-01T13:29:32Z 2021-10-01T13:29:32Z CONTRIBUTOR

@pl-marasco Thanks for the example ! With it I have the same result as you, it takes the same time with patch or with compute.

However, I could construct an example giving very different results. It is quite close to my original code:

``` time_start = time.perf_counter() COORDS = dict( time=pd.date_range("2042-01-01", periods=200, freq=pd.DateOffset(days=1)), ) da = xr.DataArray( np.random.rand(200 * 3500 * 350).reshape((200, 3500, 350)), dims=('time', 'x', 'y'), coords=COORDS ).chunk(dict(time=-1, x=100, y=100))

resampled = da.resample(time="MS")

for label, sample in resampled:
    # sample = sample.compute()
    idx = sample.argmax('time')
    sample.isel(time=idx)

time_elapsed = time.perf_counter() - time_start
print(time_elapsed, " secs")

``` (Basically I want for each month the first event occurring in it).

Without the patch and uncommenting sample = sample.compute(), it takes 5.7 secs. With the patch it takes 53.9 seconds.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  374025325
Powered by Datasette · Queries took 0.821ms · About: xarray-datasette