Open ruimmpires opened 5 years ago
also tried to force the dimension to be integer, but now get many weird errors: training_data = pd.read_csv('training_data.data', dtype={"diameter": np.int32}) header = training_data.columns
The training_data.data is now: "color","diameter","label" 'Green',3,'Apple' 'Yellow',3,Apple' 'Red',1,'Grape' 'Red',1,'Grape' 'Yellow',3,'Lemon'
Traceback (most recent call last): File "/home/rpires/.local/lib/python3.7/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: 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "decision_tree_withCSVdata.py", line 410, in
the code works fine! However I am a newbie and tried to make editing the training data a bit more easy so I've created a file training_data.data as: Green,3,Apple Yellow,3,Apple Red,1,Grape Red,1,Grape Yellow,3,Lemon and then import this with: import pandas as pd training_data = pd.read_csv('training_data.data', header=-1)
and now I gut the error TypeError: 'int' object is not subscriptable.