0
I create a program to read from a file csv
a set of coordinates and stores them in an object DataFrame
. The code goes below
df = pandas.read_csv(os.getcwd() + "/Coordinates.csv")
print(df["Longitude"])
The csv file is as follows:
Longitude;Latitude
10;10
11.3;11.9
12.4;10.3
9.2;10.4
When running this code the following error is shown:
File "/home/bruno/.local/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2522, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 117, in
pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 139, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1265, in
pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1273, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'longitude'
When printing column value with obtain:
Index(['Longitude;Latitude'], dtype='object')
My question is whether the columns are being read correctly, why the keyError