Wenn wir einen listenähnlichen Schlüssel haben, erhöht _check_indexing_error im DatensatzPython

Python-Programme
Anonymous
 Wenn wir einen listenähnlichen Schlüssel haben, erhöht _check_indexing_error im Datensatz

Post by Anonymous »

Ich versuche diesen Wohnungsdatensatz, um zu holen, wie viele Häuser, die vor 1960 gebaut wurden

Code: Select all

g = df[(df["built"] < 1960)]
< /code>
KeyError < /p>
Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/pandas/core/indexes/base.py in get_loc(self, key)
3804         try:
-> 3805             return self._engine.get_loc(casted_key)
3806         except KeyError as err:

index.pyx in pandas._libs.index.IndexEngine.get_loc()

index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'built'

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

KeyError                                  Traceback (most recent call last)
2 frames
/usr/local/lib/python3.11/dist-packages/pandas/core/indexes/base.py in get_loc(self, key)
3810             ):
3811                 raise InvalidIndexError(key)
-> 3812             raise KeyError(key) from err
3813         except TypeError:
3814             # If we have a listlike key, _check_indexing_error will raise

KeyError: 'built'
Bildbeschreibung hier eingeben

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post