VIBHU BAROT :
I have xarray from netcdf file which looks like this.
Dimensions: (latitude: 721, longitude: 1440, time: 41)
Coordinates:
* longitude (longitude) float32 0.0 0.25 0.5 0.75 ... 359.25 359.5 359.75
* latitude (latitude) float32 90.0 89.75 89.5 89.25 ... -89.5 -89.75 -90.0
expver int32 1
* time (time) datetime64[ns] 1979-01-01 1980-01-01 ... 2019-01-01
Data variables:
z (time, latitude, longitude) float32 50517.914 ... 49769.473
Attributes:
Conventions: CF-1.6
history: 2020-03-02 12:47:40 GMT by grib_to_netcdf-2.16.0: /opt/ecmw...
I want to get mean of values of z along latitude and longitude.
I'm trying this code:
df.mean(axis = 0)
But it's losing some of coordinates. and returning me something like this.
Dimensions: (latitude: 721, longitude: 1440)
Coordinates:
expver int32 1
Dimensions without coordinates: latitude, longitude
Data variables:
z (latitude, longitude) float32 49742.03 49742.03 ... 50306.242
Am I doing something wrong here. Please help me with this.
bwc :
You need to specify by dimension (dim
) instead of axis
.
Use df.mean(dim='longitude')
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=220123&siteId=1