Open ChenggongWang opened 6 months ago
source - main
Source
This bug is caused by code here and can be reproduced by following code.
import pandas as pd import numpy as np time = pd.date_range("2000-01-01", freq="h", periods=365 * 24) ds = xr.Dataset({"foo": ("time", np.arange(365 * 24)), "time": time}) print('raw') print(ds.time) print('corrected resample') print(ds.resample(time='1ME').mean(dim="time", keep_attrs=True, skipna=False).time) print('current resample loses the time coordinate information') print(ds.resample(time='1ME').mean(dim="time", keep_attrs=True, skipna=False, keepdims=True).time)
output
raw Size: 70kB array(['2000-01-01T00:00:00.000000000', '2000-01-01T01:00:00.000000000', '2000-01-01T02:00:00.000000000', ..., '2000-12-30T21:00:00.000000000', '2000-12-30T22:00:00.000000000', '2000-12-30T23:00:00.000000000'], dtype='datetime64[ns]') Coordinates: * time (time) datetime64[ns] 70kB 2000-01-01 ... 2000-12-30T23:00:00 corrected resample Size: 96B array(['2000-01-31T00:00:00.000000000', '2000-02-29T00:00:00.000000000', '2000-03-31T00:00:00.000000000', '2000-04-30T00:00:00.000000000', '2000-05-31T00:00:00.000000000', '2000-06-30T00:00:00.000000000', '2000-07-31T00:00:00.000000000', '2000-08-31T00:00:00.000000000', '2000-09-30T00:00:00.000000000', '2000-10-31T00:00:00.000000000', '2000-11-30T00:00:00.000000000', '2000-12-31T00:00:00.000000000'], dtype='datetime64[ns]') Coordinates: * time (time) datetime64[ns] 96B 2000-01-31 2000-02-29 ... 2000-12-31 current resample loses the time coordinate information Size: 96B array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) Dimensions without coordinates: time
Suggestion: keepdims=True should be removed.
keepdims=True
No response
Version
source - main
On which installation method(s) does this occur?
Source
Describe the issue
This bug is caused by code here and can be reproduced by following code.
output
Suggestion:
keepdims=True
should be removed.Environment details
No response