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/7193#issuecomment-1287593498,https://api.github.com/repos/pydata/xarray/issues/7193,1287593498,IC_kwDOAMm_X85Mvx4a,38346144,2022-10-22T02:51:50Z,2022-10-22T09:51:43Z,NONE,"> Thanks @weipeng1999 . Can you please provide a minimal example showing the syntax and expected output?
Can I just copy from the [doc](https://docs.xarray.dev/en/stable/user-guide/indexing.html#more-advanced-indexing) and use comment to mention the change
``` python
In [100]: da = xr.DataArray(
....: np.random.rand(4, 2),
....: [
....: (""time"", pd.date_range(""2000-01-01"", periods=4)),
....: (""space"", [""IA"", ""IL""]), # do not have the ""IN"" label
....: ],
....: )
In [101]: times = xr.DataArray(
....: pd.to_datetime([""2000-01-03"", ""2000-01-02"", ""2000-01-01""]), dims=""new_time""
....: )
In [102]: # use .reindex instead of .sel
....: # and give the parameter : ""fill_value""
....: da.reindex(space=xr.DataArray([""IA"", ""IL"", ""IN""], dims=[""new_time""]), time=times, fill_value=np.nan)
Out[102]:
array([0.92, 0.34, NaN]) # so fill the missing value by np.nan
Coordinates:
time (new_time) datetime64[ns] 2000-01-03 2000-01-02 2000-01-01
space (new_time)