Open ashbeekim opened 2 years ago
@oliviachchoi HELP ME!!!
현재 출력된 에러메시지는 다음과 같습니다.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2897 try:
-> 2898 return self._engine.get_loc(casted_key)
2899 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 275
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
6 frames
pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2898 return self._engine.get_loc(casted_key)
2899 except KeyError as err:
-> 2900 raise KeyError(key) from err
2901
2902 if tolerance is not None:
KeyError: 275
line 30
AS-IS
lenC.append(len(cols))
TO-BE
lenC.extend([len(cols) for cnt in range(len(cols))])
현재 모듈 내 flow 에러 지점 확인 시 참고바랍니다.
<ipython-input-12-053bfe59d6bc> in <module>()
----> 1 data = DHL()
<ipython-input-11-c8f0d5f6e3b6> in __init__(self)
15
16 def __init__(self):
---> 17 self.train, self.match_cols = self.convert_code("train")
18 self.test = self.convert_code("test")
19
<ipython-input-11-c8f0d5f6e3b6> in convert_code(self, datas)
67 _t = (re.sub("[^a-zA-Z]", "", _r)).lower()
68 comp = eval(f"self.{_t}_df")
---> 69 DF[_a] = DF[_d].apply(lambda x: comp[x][_r])
70
71 if datas == "train":
/usr/local/lib/python3.7/dist-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
4211 else:
4212 values = self.astype(object)._values
-> 4213 mapped = lib.map_infer(values, f, convert=convert_dtype)
4214
4215 if len(mapped) and isinstance(mapped[0], Series):
pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
<ipython-input-11-c8f0d5f6e3b6> in <lambda>(x)
67 _t = (re.sub("[^a-zA-Z]", "", _r)).lower()
68 comp = eval(f"self.{_t}_df")
---> 69 DF[_a] = DF[_d].apply(lambda x: comp[x][_r])
70
71 if datas == "train":
/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py in __getitem__(self, key)
2904 if self.columns.nlevels > 1:
2905 return self._getitem_multilevel(key)
-> 2906 indexer = self.columns.get_loc(key)
2907 if is_integer(indexer):
2908 indexer = [indexer]
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2898 return self._engine.get_loc(casted_key)
2899 except KeyError as err:
-> 2900 raise KeyError(key) from err
2901
2902 if tolerance is not None:
KeyError: 275
co-author : @qkrwjdduf159, @AshbeeKim