Я хочу сохранить столбец значений из "coins_info.txt" в переменную списка в моей программе. Вот содержимое "coins_info.txt":
Name,ICO,Max,USD_ROI
Bitcoin,0.0,19535.7,N/A
Ethereum,0.0,1389.18,N/A
Ripple,0.0,3.6491,N/A
Bitcoin Cash,0.0,4091.7,N/A
EOS,0.99,21.4637,2068.05%
Litecoin,0.0,366.153,N/A
...
Я хочу получить ICO из каждой монеты в "coins_info.txt" и сохранить ее в списке, который выглядит следующим образом:
icos = [0.0, 0.0, 0.0, 0.0, 0.99, 0.0, ...]
Я попробовал этот код:
import pandas as pd
df = pd.read_csv("coins_info.txt")
icos = df["ICO"].values.tolist()
Но я получил эту ошибку для строки 4 моего кода:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2442, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5280)
File "pandas/_libs/index.pyx", line 154, in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5126)
File "pandas/_libs/hashtable_class_helper.pxi", line 1210, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20523)
File "pandas/_libs/hashtable_class_helper.pxi", line 1218, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20477)
KeyError: 'ICO'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "temp.py", line 280, in <module>
init_max_prices("btc.txt", "init")
File "temp.py", line 212, in init_max_prices
icos = df["ICO"].values.tolist()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/frame.py", line 1964, in __getitem__
return self._getitem_column(key)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/frame.py", line 1971, in _getitem_column
return self._get_item_cache(key)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/generic.py", line 1645, in _get_item_cache
values = self._data.get(item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/internals.py", line 3590, in get
loc = self.items.get_loc(item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2444, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5280)
File "pandas/_libs/index.pyx", line 154, in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5126)
File "pandas/_libs/hashtable_class_helper.pxi", line 1210, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20523)
File "pandas/_libs/hashtable_class_helper.pxi", line 1218, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20477)
KeyError: 'ICO'
Что я могу сделать, чтобы исправить мой код?