Hi everybody!
I would just love another set of eyes to look over my code... I have used xarray.Dataset.assign a good number of times in other places, but it seems to be acting weird in this instance. I am trying to add this new list, 'lapse_rate', as a variable in df (which is an existing dataset), but it seems to want to add it to the coordinates for some reason. (I have even tried to use xarray.Dataset.reset_coords to just move it despite this, but it gives me an error)
Thanks!
You can assign it with a tuple specifiying the dimension:
df = df.assign(lapse_rate = ('height', lr))
That's great, thanks Hendrik! Some error I had gotten had suggested doing that, but I couldn't figure out the formatting, so I appreciate you showing me how it's done!
Last updated: May 16 2025 at 17:14 UTC