Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 445

How to delete rows in an xarray containing a certain value of date?

$
0
0

I have an xarray containing data from an NetCDF4 data file.This xarray has a time dimension where several rows probably contain missing data. Their time stamp is always '1904-01-01T00:00:00.000000'. But no specific NAN values. Also the other data columns have different than NAN unvalid values.How can I delete these total rows anyhow?

The time dimension of the xarray looks like:

<xarray.DataArray 'time' (time: 5760)>array(['2018-02-21T00:00:04.000000000', '2018-02-21T00:00:19.000000000','1904-01-01T00:00:00.000000000','2018-02-21T00:00:34.000000000',         ..., '2018-02-21T23:59:52.000000000', '1904-01-01T00:00:00.000000000','1904-01-01T00:00:00.000000000','2018-02-21T23:59:58.000000000','1904-01-01T00:00:00.000000000'],      dtype='datetime64[ns]')

Aimed look is like:

<xarray.DataArray 'time' (time: 5760)>array(['2018-02-21T00:00:04.000000000', '2018-02-21T00:00:19.000000000','2018-02-21T00:00:34.000000000',         ..., '2018-02-21T23:59:52.000000000', '2018-02-21T23:59:58.000000000'],      dtype='datetime64[ns]')

The xarray computation guide doesn't help me in that case.

dropna won't work as there is not really any NANs.ThenI tried withDS = DS[DS.time != '2020-01-01T00:00:00']and DS = DS.where(DS.time > '2020-01-01T00:00:00') but that all wouldn't work on xarrays.

How is the correct way handling that problem?


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>