-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNettoyage.py
More file actions
101 lines (71 loc) · 3.25 KB
/
Nettoyage.py
File metadata and controls
101 lines (71 loc) · 3.25 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
def nettoyage_marque(fichier):
fichier['Marque'] = fichier['Marque'].str.extract(r'(Samsung|Apple|Huawei|TWS|Xiaomi|Sony|JBL|Beats|SAMSUNG|Jbl|HUAWEI|AKG|APPLE|Lenovo|LIVOO|Redmi|AUKEY|Google|Sony|Asus|Cubot|Nokia|Alcatel|Oneplus|Honor|Nubia|BlackBerry|Oukitel|ASUS|REALME|OPPO|Realme|LG|Nubia|OUKITEL|Nokia| BlackBerry| Realme| APPLE| Alcatel| Asus| Samsung| Apple| OPPO| Google| Sony| ASUS| LG| HUAWEI| Huawei| Honor| Xiaomi|OnePlus|)')
for i in range(len(fichier)):
if len(fichier['Marque'][i])==0:
fichier['Marque'][i]="Inconnu"
fichier['Marque'] = [x.lower() for x in fichier['Marque']]
def nettoyage_ecran(fichier):
for i in range(len(fichier)):
obool=True
if fichier['écran'][i][:3]!="['E" or fichier['reseau'][i][:4]!="['Ré":
fichier.drop(i,0,inplace=True)
fichier['écran'] = [x.replace( "['Ecran ","") for x in fichier['écran']]
fichier['écran'] = fichier['écran'].str[:-3]
fichier=fichier.reset_index()
def nettoyage_reseau(fichier):
fichier.loc[fichier["reseau"] == "['Réseau 5G']","reseau"] ="5G"
fichier.loc[fichier["reseau"] == "['Réseau 4G']","reseau"] = "4G"
fichier.loc[fichier["reseau"] == "['Réseau 3G']","reseau"] = "3G"
def nettoyage_prix(fichier):
fichier['prix'] = [x.replace( "['","") for x in fichier['prix']]
fichier['prix'] = [x.replace( " €']","") for x in fichier['prix']]
fichier['prix'] = [x.replace(',', '.') for x in fichier['prix']]
fichier['prix'] = [x.replace( " ","") for x in fichier['prix']]
fichier['prix'] = [x.strip() for x in fichier['prix']]
fichier['prix'] = [x.replace( "nan","100") for x in fichier['prix']]
try:
fichier['prix']=pd.to_numeric(fichier['prix'])
except:
print()
def nettoyage_exploit(fichier):
fichier['exploit'] = [x.replace( "['","") for x in fichier['exploit']]
fichier['exploit'] = [x.replace( "']","") for x in fichier['exploit']]
def col_Ram(fichier):
Ram=[]
for i in range(len(fichier.exploit)):
try :
head, sep, tail = fichier.exploit.iloc[i].partition('/')
if tail=="":
carac="Inconnu"
else:
carac=tail
except:
print()
Ram.append(carac)
fichier['Ram']=Ram
fichier['Ram'] = [x.replace( "Series 60 v5.0","Inconnu") for x in fichier['Ram']]
fichier['Ram'] = [x.replace( "Series 60 3.1 Edition","Inconnu") for x in fichier['Ram']]
def cor_exploit(fichier):
exploit=[]
for i in range(len(fichier.exploit)):
try :
head, sep, tail = fichier.exploit.iloc[i].partition('/')
carac=head
except:
print()
exploit.append(carac)
fichier['exploit']=exploit
def col_memoire(fichier):
memoire=[]
for i in range(len(fichier.exploit)):
try :
head, sep, tail = fichier.exploit.iloc[i].partition('Mémoire')
if tail=="":
carac="Inconnu"
else:
carac=tail
except:
print()
memoire.append(carac)
fichier['Mémoire']=memoire
fichier['Mémoire'] = [x.replace( "Go","") for x in fichier['Mémoire']]