'xarray dataset not reading longitude/latitude data in a way I can subset

Hey so I am using NOAA weather data and I am trying to select longitude and latitude variables.

I simply want to make a variable called lat and lon that is equal to latitude and longitude values from the dataset. The latitude/longitude variables are not the same "type" as temperature based on the data when I print the dataset. (you can see in the photo). Is there any way to get that "type" of data to be equal to the temperature/time data in that dataset? enter image description here

I am sorry for being bad at explaining it since part of the reason I am confused is why it sees these coordinate variables as different from temperature..

Here is information about the dataset.. I guess the coordinates are float64

Coordinates:
    time        datetime64[ns] ...
    step        timedelta64[ns] ...
    surface     float64 ...
  * latitude    (latitude) float64 25.0 25.25 25.5 25.75 ... 54.5 54.75 55.0
  * longitude   (longitude) float64 235.0 235.2 235.5 ... 294.5 294.8 295.0
    valid_time  datetime64[ns] ...
Data variables:
    t           (latitude, longitude) float32 ...

The reason why i am asking this question is because I am trying to simply subset data based on latitude/longitude

GFS3 = GFS3[(GFS3["longitude"]==280.25) & (GFS3["lat"]==40)]

But when I run it I get the error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "C:\Users\kevin\.spyder-py3\temp.py", line 77, in <module>
    GFS3 = GFS3[(GFS3["longitude"]==280.25) & (GFS3["lat"]==40)]

  File "C:\Users\kevin\anaconda3\envs\flight\lib\site-packages\pandas\core\frame.py", line 3505, in __getitem__
    indexer = self.columns.get_loc(key)

  File "C:\Users\kevin\anaconda3\envs\flight\lib\site-packages\pandas\core\indexes\base.py", line 3623, in get_loc
    raise KeyError(key) from err

KeyError: 'longitude'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source