1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 subset0 = training_set.loc[training_set.iloc[:,0] == 0, 1:].describe().T
2 subset1 = training_set.loc[training_set.iloc[:,0] == 1, 1:].describe().T
3 print(subset0.loc[:,'min'].mean())
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexing.py:1147, in _LocationIndexer.__getitem__(self, key)
1145 if self._is_scalar_access(key):
1146 return self.obj._get_value(*key, takeable=self._takeable)
-> 1147 return self._getitem_tuple(key)
1148 else:
1149 # we by definition only have the 0th axis
1150 axis = self.axis or 0
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexing.py:1339, in _LocIndexer._getitem_tuple(self, tup)
1336 if self._multi_take_opportunity(tup):
1337 return self._multi_take(tup)
-> 1339 return self._getitem_tuple_same_dim(tup)
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexing.py:994, in _LocationIndexer._getitem_tuple_same_dim(self, tup)
991 if com.is_null_slice(key):
992 continue
--> 994 retval = getattr(retval, self.name)._getitem_axis(key, axis=i)
995 # We should never have retval.ndim < self.ndim, as that should
996 # be handled by the _getitem_lowerdim call above.
997 assert retval.ndim == self.ndim
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexing.py:1373, in _LocIndexer._getitem_axis(self, key, axis)
1371 if isinstance(key, slice):
1372 self._validate_key(key, axis)
-> 1373 return self._get_slice_axis(key, axis=axis)
1374 elif com.is_bool_indexer(key):
1375 return self._getbool_axis(key, axis=axis)
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexing.py:1405, in _LocIndexer._get_slice_axis(self, slice_obj, axis)
1402 return obj.copy(deep=False)
1404 labels = obj._get_axis(axis)
-> 1405 indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop, slice_obj.step)
1407 if isinstance(indexer, slice):
1408 return self.obj._slice(indexer, axis=axis)
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py:6602, in Index.slice_indexer(self, start, end, step)
6558 def slice_indexer(
6559 self,
6560 start: Hashable | None = None,
6561 end: Hashable | None = None,
6562 step: int | None = None,
6563 ) -> slice:
6564 """
6565 Compute the slice indexer for input labels and step.
6566
(...)
6600 slice(1, 3, None)
6601 """
-> 6602 start_slice, end_slice = self.slice_locs(start, end, step=step)
6604 # return a slice
6605 if not is_scalar(start_slice):
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py:6819, in Index.slice_locs(self, start, end, step)
6817 start_slice = None
6818 if start is not None:
-> 6819 start_slice = self.get_slice_bound(start, "left")
6820 if start_slice is None:
6821 start_slice = 0
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py:6734, in Index.get_slice_bound(self, label, side)
6730 original_label = label
6732 # For datetime indices label may be a string that has to be converted
6733 # to datetime boundary according to its resolution.
-> 6734 label = self._maybe_cast_slice_bound(label, side)
6736 # we need to look up the label
6737 try:
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py:6667, in Index._maybe_cast_slice_bound(self, label, side)
6665 # reject them, if index does not contain label
6666 if (is_float(label) or is_integer(label)) and label not in self:
-> 6667 self._raise_invalid_indexer("slice", label)
6669 return label
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py:4306, in Index._raise_invalid_indexer(self, form, key, reraise)
4304 if reraise is not lib.no_default:
4305 raise TypeError(msg) from reraise
-> 4306 raise TypeError(msg)
TypeError: cannot do slice indexing on Index with these indexers [1] of type int |
Partager