I creating a program to read from a file csv
a set of coordinates and store them in a DataFrame
object. The code is 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 you run this code the following error is displayed:
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 the value of columns with get:
Index(['Longitude;Latitude'], dtype='object')
My question is whether the columns are being read correctly, why keyError