attack-datasources icon indicating copy to clipboard operation
attack-datasources copied to clipboard

KeyError: "['x_mitre_is_subtechnique'] not in index"

Open System-CTL opened this issue 4 years ago • 1 comments

  • This error occurs in the notebook_functions.py file at the get_attack_dataframe function.

Below Commands in .ipnyb file reproduce this error: attack = get_attack_dataframe() attack.head()

output :

KeyError Traceback (most recent call last) Input In [32], in ----> 1 attack = get_attack_dataframe() 2 attack.head()

File D:\Dec-\attack-datasources-main\docs\scripts\notebook_functions.py:57, in get_attack_dataframe(matrix) 53 attck = json_normalize(attck) 54 # view available columns - my line 55 #print(attck.columns) 56 # selecting columns ---> 57 attck = attck[['technique_id','x_mitre_is_subtechnique','technique','tactic','platform','data_sources']] 59 # Splitting data_sources field 60 attck = attck.explode('data_sources').reset_index(drop=True)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py:3464, in DataFrame.getitem(self, key) 3462 if is_iterator(key): 3463 key = list(key) -> 3464 indexer = self.loc._get_listlike_indexer(key, axis=1)[1] 3466 # take() does not accept boolean indexers 3467 if getattr(indexer, "dtype", None) == bool:

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexing.py:1314, in _LocIndexer._get_listlike_indexer(self, key, axis) 1311 else: 1312 keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr) -> 1314 self._validate_read_indexer(keyarr, indexer, axis) 1316 if needs_i8_conversion(ax.dtype) or isinstance( 1317 ax, (IntervalIndex, CategoricalIndex) 1318 ): 1319 # For CategoricalIndex take instead of reindex to preserve dtype. 1320 # For IntervalIndex this is to map integers to the Intervals they match to. 1321 keyarr = ax.take(indexer)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexing.py:1377, in _LocIndexer._validate_read_indexer(self, key, indexer, axis) 1374 raise KeyError(f"None of [{key}] are in the [{axis_name}]") 1376 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique()) -> 1377 raise KeyError(f"{not_found} not in index")

KeyError: "['x_mitre_is_subtechnique'] not in index"

System-CTL avatar Jan 24 '22 22:01 System-CTL

Replace all 'x_mitre_is_subtechnique' with 'is_subtechnique' will fix this issue. image

rav1and3 avatar Jul 31 '22 20:07 rav1and3

Admin note: closing all remaining issues and pull requests prior to archiving the repository

jondricek avatar Sep 13 '23 15:09 jondricek