-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataAnalysis.py
More file actions
128 lines (96 loc) · 2.25 KB
/
Copy pathdataAnalysis.py
File metadata and controls
128 lines (96 loc) · 2.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
acciones = {"SAN":3.14, "REP":14.1, "IBM":139, "MSFT":[1, 5, 6]}
print(type(acciones))
print(acciones)
acciones["REP"]
acciones["REP"] = 15
acciones["REP"]
acciones.update({"REP":21})
print(acciones["REP"])
acciones.update({"TEL":34})
acciones["TEL"]
print(acciones)
print("REP" in acciones)
if "REP" in acciones:
print("Sí")
for key, value in acciones.items():
print(key, value)
for key in acciones.keys():
print(key)
for value in acciones.values():
print(value)
accionesEj = {"AENA.MC":143.75, "BBVA.MC":6.34, "REP.MC":14.22, "SAN.MC":3.324}
print(type(accionesEj))
print(accionesEj["BBVA.MC"])
accionesEj.update({"OHLA.MC":0.518, "ANE.MC":34.32, "TEF.MC":3.811})
print(accionesEj)
# sumaTotal = []
# for value in accionesEj.values():
# if value == "SAN.MC":
# accionesEj.pop()
# sumaTotal.append(value)
# # sumaTotal.pop("SAN.MC")
# print(accionesEj)
# sum(sumaTotal)
total = 0
for key, value in accionesEj.items():
if key != "SAN.MC":
total += value
print(f"El total es ${total}")
import json
acciones = {"SAN":3.14, "REP":14.1, "IBM":139}
# para convertir un JSON en string
s = json.dumps(acciones)
print(type(s))
print(s)
# para convertir un string en Dicc
dicc = json.loads(s)
print(type(dicc))
print(dicc)
# import json
test = """{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
}"""
s = json.loads(test)
print(type(s))
print(s)
dicc = json.dumps(test)
print(type(dicc))
print(dicc)
import pandas as pd
datos = {"SAN":3.14, "REP":14.1, "IBM":129}
series = pd.Series(datos)
print(series)
series.loc["REP"]
datos = [45, 23, 7, 5, 8, 9, 10]
series = pd.Series(datos)
print(series)
series.loc[4]
series.iloc[4]
datos = [45, 23, 7, 5, 8, 9, 10]
series = pd.Series(datos)
print(series.sum())
print(series.nsmallest(n=3))
series.mean()
series.describe()
series.head(2)
series.tail(2)