I load data from a csv file. When I try to save the labels column into a variable I am getting the error saying label, and the dataset was taken from https://www.kaggle.com/c/digit-recognizer/data
d0 = pd.read_csv('./test.csv')
print(d0.head(5)) # print first five rows of d0.
# to save the labels into a variable l.
l = (d0['label'])
got output:
pixel0 pixel1 pixel2 pixel3 pixel4 pixel5 pixel6 pixel7 pixel8 \
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0
pixel9 ... pixel774 pixel775 pixel776 pixel777 pixel778 \
0 0 ... 0 0 0 0 0
1 0 ... 0 0 0 0 0
2 0 ... 0 0 0 0 0
3 0 ... 0 0 0 0 0
4 0 ... 0 0 0 0 0
pixel779 pixel780 pixel781 pixel782 pixel783
0 0 0 0 0 0
1 0 0 0 0 0
2 0 0 0 0 0
3 0 0 0 0 0
4 0 0 0 0 0
[5 rows x 784 columns]
I'm getting error
KeyError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3077 try: -> 3078 return self._engine.get_loc(key) 3079 except KeyError: KeyError: 'label'
During handling of the above exception, another exception occurred:KeyError Traceback (most recent call last) in 15 16 # save the labels into a variable l. ---> 17 l = (d0['label']) 18 19 # Drop the label feature and store the pixel data in d.
KeyError: 'label'
I cant understand the error described in anaconda
Dropped some error code as stack is showing add more detail error
Please help me on solving this problem