-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtempCodeRunnerFile.python
50 lines (38 loc) · 1.06 KB
/
tempCodeRunnerFile.python
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
import numpy as np
import geopandas as gpd
import matplotlib.pyplot as plt
import pandas as pd
##
where = 'Téléchargements/velib_358.csv'
velib = pd.read_csv(where, sep=';')
##
from json import loads
station = velib.loc[0]
jour = station['10/19/20;18:01:51'] #exemple de ce qu'est un jour
def dico(jour):
if isinstance(jour, str):
dia = '{' + jour[2:-2].replace('{','').replace('}','').replace("'",'"') + '}'
return(loads(dia))
else:
print(jour)
return(jour)
test = dico(jour)
test
##
col_vide = '[{}, {}]'
colonnes_vides = []
for j in velib.columns:
if velib[j][0] == col_vide:
print(j)
colonnes_vides.append(j)
velib=velib.drop(colonnes_vides, axis=1)
##
tete = velib.head()
print(tete)
cols = velib.columns
te = tete[cols[:5]]
te #sous-sections de la database sur lesquelles travailler pour tester
##
for j in velib.columns[1:]: #sans la colonne station_id
velib[j] = [dico(i) for i in velib[j]] #ça serait ptet mieux avec un map
velib.to_csv(r"C:\Users\mathi\Desktop\Projet info\donnees\velib_clean.csv")