# Calcul sur dataframe

**URL:** <https://forumia.fr/t/calcul-sur-dataframe/289>\
**Category:** Général\
**Created:** [Août 6, 2024, 3:22 UTC](https://forumia.fr/t/calcul-sur-dataframe/289 "2024-08-06T15:22:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sas714](https://forumia.fr/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@sas714](https://forumia.fr/u/sas714)\
**Post date:** [Août 6, 2024, 3:22 UTC](https://forumia.fr/t/calcul-sur-dataframe/289/1 "2024-08-06T15:22:11Z")

</div>

bonjour merci d’avance pour votre aide je suis bloque sur ce code`import pandas as pd  
import numpy as np  
import os  
import sys  
import tensorflow as tf  
from matplotlib import pyplot as plt  
from matplotlib.ticker import StrMethodFormatter  
from natsort import natsorted  
from scipy import stats  
from tensorflow.python.framework import ops  
%matplotlib inline

## training\_set = pd.read\_csv(‹&nbsp;/Users/user/Downloads/Earthquakes/Earthquakes\_TRAIN.csv&nbsp;›) test\_validation\_set = pd.read\_csv(‹&nbsp;/Users/user/Downloads/Earthquakes/Earthquakes\_TEST.csv&nbsp;›) training\_set.iloc[:,0].unique()`l'erreur est a cette cellule`subset0 = training\_set.loc[training\_set.iloc[:,0] == 0, 1:].describe().T subset1 = training\_set.loc[training\_set.iloc[:,0] == 1, 1:].describe().T print(subset0.loc[:,‹&nbsp;min&nbsp;›].mean()) print(subset1.loc[:,‹&nbsp;min&nbsp;›].mean())`elle produit`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[:,‹&nbsp;min&nbsp;›].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 «&nbsp;&nbsp;»"  
6565 Compute the slice indexer for input labels and step.  
6566  
(…)  
6600 slice(1, 3, None)  
6601 «&nbsp;&nbsp;»"  
 → 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, «&nbsp;left&nbsp;»)  
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(«&nbsp;slice&nbsp;», 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`  
les données se trouvent ici  
[[https://www.timeseriesclassification](https://www.timeseriesclassification)…et=Earthquakes]
