Untitled
unknown
plain_text
2 years ago
2.4 kB
10
Indexable
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Input In [28], in <cell line: 9>()
6 data = df.copy()
8 # Reshape the dataset into a transactional format
----> 9 transactions = data[['ticket_category', 'ticket_type', 'ticket_item', 'ticket_summary',
10 'ticket_severity', 'resolution_sla_violated', 'reopen_count',
11 'role_id', 'ticket_resolution_time']].values.tolist()
13 # Apply one-hot encoding to convert the data into a suitable format for Apriori algorithm
14 te = TransactionEncoder()
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pandas/core/frame.py:3461, in DataFrame.__getitem__(self, key)
3459 if is_iterator(key):
3460 key = list(key)
-> 3461 indexer = self.loc._get_listlike_indexer(key, axis=1)[1]
3463 # take() does not accept boolean indexers
3464 if getattr(indexer, "dtype", None) == bool:
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/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 /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pandas/core/indexing.py:1374, in _LocIndexer._validate_read_indexer(self, key, indexer, axis)
1372 if use_interval_msg:
1373 key = list(key)
-> 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: "None of [Index(['ticket_category', 'ticket_type', 'ticket_item', 'ticket_summary',\n 'ticket_severity', 'resolution_sla_violated', 'reopen_count', 'role_id',\n 'ticket_resolution_time'],\n dtype='object')] are in the [columns]"Editor is loading...