I'm trying to Make "ID" as Index, it throws error mentioned below and image:
obj= pd.read_csv("Supermarkets.csv")
obj
ID Address City Country Name Number
0 1 Ecity-1 Bangalore India village mart 2
1 2 Ecity-2 Mysore India More 3
2 3 Ecity-3 Dharwad India Bigg bazar 1
3 4 Ecity-4 Haveri India Super Mart 2
4 5 Ecity-5 Badami India Kirani angadi 1
obj.set_index("ID")
Error:
Traceback (most recent call last):
File "C:\Users\sharathkumar.chattar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexes\base.py", line 2656, in get_loc
return self._engine.get_loc(key)
File "pandas\_libs\index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'ID'

print(obj.columns)? does this work afterobj.columns = obj.columns.str.strip()..??