Despite x printing True when tested alone, I keep getting errno 22 import numpy as np import pandas as pd import xarray as xr import os # Load the dataset x = xr.open_dataset( r"C:/Users/rune/grib predictions/day 1 long .grib", engine="cfgrib", backend_kwargs={"indexpath": ""} ) # Check coordinate names print(x.coords) # Extract latitude and longitude variables lat = x["latitude"] long = x["longitude"] # Sort dataset by latitude and longitude x = x.sortby(["latitude", "longitude"]) # Convert longitude from [0, 360] to [-180, 180] x["longitude"] = x["longitude"].where(x["longitude"] <= 180, x["longitude"] - 360) # Extract Santa Cruz region santa_cruz_array = x.sel(latitude=slice(35.0, 40.0), longitude=slice(-125.0, -120.0)) # Convert to Pandas DataFrame santa_cruz = santa_cruz_array.to_dataframe().reset_index() # Sort by latitude and longitude santa_cruz.sort_values(by=["latitude", "longitude"], inplace=True) # Replace missing values with column mean santa_cruz.fillna(santa_cruz.mean(), inplace=True) print(santa_cruz) I have tried making comparison between different version, using AI and testing if the path itself is the problem but it still appears to print succesfully Continue reading...