NDBC is broken after the latest update of `ndbc_api`
$ python -c 'import searvey; searvey.get_ndbc_stations()'
Traceback (most recent call last):
File "/home/panos/Prog/poseidon/searvey/.venv/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
return self._engine.get_loc(casted_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pandas/_libs/index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7096, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Location Lat/Long'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/panos/Prog/poseidon/searvey/searvey/_ndbc_api.py", line 100, in get_ndbc_stations
ndbc_stations = _get_ndbc_stations(
^^^^^^^^^^^^^^^^^^^
File "/home/panos/Prog/poseidon/searvey/searvey/_ndbc_api.py", line 35, in _get_ndbc_stations
stations_df[["lat", "ns", "lon", "ew"]] = stations_df["Location Lat/Long"].str.extract(
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/home/panos/Prog/poseidon/searvey/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 4107, in __getitem__
indexer = self.columns.get_loc(key)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/panos/Prog/poseidon/searvey/.venv/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3819, in get_loc
raise KeyError(key) from err
KeyError: 'Location Lat/Long'
Hii @pmav99 I am Safwan, a Data Science Student. I am interested in IOOS, and I am also new to open source, so I would like to work on this issue. May I be assigned?
Hi, @Safwannn89 can you reproduce this error? Today I tested it on my machine and I don't see the error.
Hii @SorooshMani-NOAA I hope you have a good day I read about the requirements and then I set up on my machine, and then I'll see that error and I also ask you a question, that do I use Python version 3.13.7.
I think 3.13 should be fine, I used 3.12. But if you want to work on this error, first I want to see if you can reproduce it. In my case I can't!
Hi @SorooshMani-NOAA,
I was able to successfully reproduce the KeyError: 'Location Lat/Long' on my end (using a stable Python 3.12 environment in Colab).
The issue is due to a change in the NDBC API column header.
My debugging confirmed that the column name the API returns is now simply "Location" (which contains the lat/long string), rather than the old, expected name, "Location Lat/Long".
Would I work on this issue?
Thanks,
@Safwannn89 interesting ... sure feel free to work on it. Can you specify in which version of NDBC this has changed? We need to pin the NDBC version to be larger than the version where this has changed as a part of your fix.