Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'lat' key not found when no metadata is given #392

Closed
vergauwenthomas opened this issue Nov 9, 2023 · 0 comments · Fixed by #390
Closed

'lat' key not found when no metadata is given #392

vergauwenthomas opened this issue Nov 9, 2023 · 0 comments · Fixed by #390
Assignees
Labels
bug Something isn't working

Comments

@vergauwenthomas
Copy link
Owner

vergauwenthomas commented Nov 9, 2023

Multiple methods rely on the 'lat' and 'lon' column. Like in the __repr__of the dataset:

 if ((not self.metadf['lat'].isnull().all()) &
            (not self.metadf['lon'].isnull().all())):
            add_info += '    *Coordinates are available for all stations. \n'

So make sure these columns are always in the metadf attribute but filled with Nan if data is unknown.

Traceback (most recent call last):

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/pandas/core/indexes/base.py:3790 in get_loc
return self._engine.get_loc(casted_key)

File index.pyx:152 in pandas._libs.index.IndexEngine.get_loc

File index.pyx:181 in pandas._libs.index.IndexEngine.get_loc

File pandas/_libs/hashtable_class_helper.pxi:7080 in pandas._libs.hashtable.PyObjectHashTable.get_item

File pandas/_libs/hashtable_class_helper.pxi:7088 in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'lat'

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

Traceback (most recent call last):

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
exec(code, globals, locals)

File ~/Documents/VLINDER_github/MetObs_toolkit/development/developscript.py:50
dataset.show()

File ~/Documents/VLINDER_github/MetObs_toolkit/metobs_toolkit/dataset.py:303 in show
print_dataset_info(self, show_all_settings)

File ~/Documents/VLINDER_github/MetObs_toolkit/metobs_toolkit/printing.py:30 in print_dataset_info
print(dataset)

File ~/Documents/VLINDER_github/MetObs_toolkit/metobs_toolkit/dataset.py:152 in str
if ((not self.metadf['lat'].isnull().all()) &

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/pandas/core/frame.py:3896 in getitem
indexer = self.columns.get_loc(key)

File ~/anaconda3/envs/metobs_dev/lib/python3.9/site-packages/pandas/core/indexes/base.py:3797 in get_loc
raise KeyError(key) from err

KeyError: 'lat'

@vergauwenthomas vergauwenthomas added the bug Something isn't working label Nov 9, 2023
@vergauwenthomas vergauwenthomas self-assigned this Nov 9, 2023
vergauwenthomas added a commit that referenced this issue Nov 9, 2023
…tion update (#390)

* update the introdction example to use the demo datafiles

* update the lcz example

* add nbsphinx to extensions

* examples in seperate folder

* converted examples into notebooks

* created a concat_save function to fix the Futurewarning of pandas for concating empyt and NA-entrie dataframes

* fixed the futurwarning when appending an emtpy multiindex

* add notebook checkpoints to the ignore

* Updated the examples for the documentation.

* delete checkpoints from git

* add new examples to the documentation

* minor bugfix when a column is not present

* minor bugfix to ensure unit conversion

* fix for #391

* exclude .py examples, use only the nootbooks for git tracking

* run documentation examples as tests + build the documentation as test

* Make sure the meta columns are kept if not metadata is available (solves #392)

* add groups to the pyproject so a poetry-documentation env can be used

* explicit provide template

* fix error in the gapfill test

* fixes sphinx warnings

* pass spell/grammer check

* pass spell/grammer check

* pass spell/grammer check

* spell and grammer check

* spell and grammer checks

* fix titles

* add titan in seperate group

* remove ipy checkpoints

* update intro wrt titanlib installation

* remove old examples that ar not relevant anymore

* update version and fixed documentation reference

* update version to beta 1.2

* avoid using the requirements file, now directly using poetry in documentation group

* gee map is always returned see codereview

* the old examples are removed so no need to scan this folder

* remove ipy checkpoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant