Я хочу извлечь несколько данных из данных модели CMIP6 и сохранить как файл NetCDF, используя следующие сценарии: < /p>
import pandas as pd
import xarray as xr
from netCDF4 import Dataset
nc_file = (r"C:\Users\DELL 3090\Desktop\Projection\RF_58\pr_Amon_AWI-CM-1-1-MR_ssp585_mm_month.nc")
NC = xr.open_dataset(nc_file)
#define locations and station id
lat=[13.3,7.5,8.5,7.9,9,7.8,11.3,14.3,14.2,7]
lon=[39.8,34.3,39.8,38.7,38.8,39.9,37.5,39.5,38.9,39.9]
name=['Abala','Abobo','Abomsa','Adamitulu','AddisAbabaBole','Adele','Adet','Adigrat','Adwa','Agarfa']
Newdf = pd.DataFrame([])
for i,j,id in zip(lat,lon,name):
dsloc = NC.sel(lat=i,lon=j,method='nearest')
DT=dsloc.to_dataframe()
# insert the name with your preferred column title:
Newdf=Newdf._append(DT,sort=True)
Newdf.to_netcdf('C:/Users/DELL 3090/Desktop/Projection\RF_58/pr_Amon_AWI-CM-1-1 MR_ssp585_mm_month111.nc', index=True, header=True)
< /code>
Но, наконец, Python отвечает на эту ошибку: < /p>
file ~ \ anaconda3 \ envs \ env_resaerch \ lib \ site-packages \ pandas \ core \ generic.py: 6204 в __getattr __
return object .__ getattribute __ (self, name)
attributeError: 'объект DataFrame' не имеет атрибута 'to_netcdf' < /p> < /blockquote>
Так что, пожалуйста, помогите мне, что я могу сделать? < /p>
Подробнее здесь: https://stackoverflow.com/questions/793 ... as-nc-file