简体   繁体   中英

Exception: Data must be 1-dimensional problem

clim = xr.open_dataset('C:/Users/90531/Desktop/Lisflood/clim_151118.nc')
clim

# extract data for selected point in netcdf file by LISFLOOD coordinates
dsloc = ds.sel(x=station.lat.values,y=station.long.values,method='nearest')
climloc = clim.sel(x=station.lat.values,y=station.long.values,method='nearest')



import pandas as pd

df = pd.DataFrame({
    'Historical_times': np.array(climloc.time.values + np.timedelta64(climloc.step.values)),
    # Historical Times from the Climatology File
    'Historical': climloc.dis24.values[:, -1, -1], # Historical Data from the Climatology file
    'TimeStep': time})  # Time data from the Ensemble Data file as Times (Base + Delta("STEP"))

These codes give error Exception: Data must be 1-dimensional . How can I solve this? Thanks.

Impossible to answer properly without seeing the structure of your data. However, each column in a dataframe has to be 1D. The following does not appear to be one:

climloc.dis24.values[:, -1, -1]

Most likely you will need to coerce this, if possible, to, for example, a 1D list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM