Examples¶
import xarray as xr
import xarray_sql as xql
ds = xr.tutorial.open_dataset('air_temperature')
ctx = xql.XarrayContext()
ctx.from_dataset('air', ds, chunks=dict(time=24))
result = ctx.sql('''
SELECT
"lat", "lon", AVG("air") as air_avg
FROM
"air"
GROUP BY
"lat", "lon"
''')
df = result.to_pandas()
df.head()