Spaces:
Sleeping
Sleeping
cha0smagick
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
|
6 |
# Lista de criptomonedas
|
7 |
cryptos = [
|
@@ -17,12 +16,7 @@ def get_crypto_data():
|
|
17 |
params = {
|
18 |
'list': ','.join(cryptos)
|
19 |
}
|
20 |
-
|
21 |
-
'x-rapidapi-host': 'coingecko.p.rapidapi.com',
|
22 |
-
'x-rapidapi-key': 'c4b66a3c25msh950412fab4eaee1p159dbfjsn4'
|
23 |
-
}
|
24 |
-
|
25 |
-
response = requests.get(url, headers=headers, params=params)
|
26 |
return response.json()
|
27 |
|
28 |
# Inicializar la aplicaci贸n
|
@@ -34,21 +28,10 @@ if st.button("Actualizar datos"):
|
|
34 |
data = get_crypto_data()
|
35 |
df = pd.DataFrame(data)
|
36 |
|
37 |
-
#
|
38 |
st.subheader("Estad铆sticas de las Criptomonedas")
|
39 |
-
st.dataframe(df[['coin', 'name', 'price', 'volume', 'algorithm', 'difficulty', 'reward_block']]
|
40 |
-
|
41 |
-
# Gr谩fica de precios
|
42 |
-
st.subheader("Fluctuaci贸n de Precios")
|
43 |
-
prices = df['price'].astype(float)
|
44 |
-
plt.figure(figsize=(10, 5))
|
45 |
-
plt.plot(prices, marker='o')
|
46 |
-
plt.title('Fluctuaci贸n de Precios de Criptomonedas')
|
47 |
-
plt.xticks(range(len(cryptos)), cryptos)
|
48 |
-
plt.xlabel('Criptomonedas')
|
49 |
-
plt.ylabel('Precio en USD')
|
50 |
-
plt.grid()
|
51 |
-
st.pyplot(plt)
|
52 |
|
53 |
else:
|
54 |
st.write("Presiona el bot贸n para actualizar los datos.")
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|
|
|
4 |
|
5 |
# Lista de criptomonedas
|
6 |
cryptos = [
|
|
|
16 |
params = {
|
17 |
'list': ','.join(cryptos)
|
18 |
}
|
19 |
+
response = requests.get(url, params=params)
|
|
|
|
|
|
|
|
|
|
|
20 |
return response.json()
|
21 |
|
22 |
# Inicializar la aplicaci贸n
|
|
|
28 |
data = get_crypto_data()
|
29 |
df = pd.DataFrame(data)
|
30 |
|
31 |
+
# Ajustar ancho de la tabla
|
32 |
st.subheader("Estad铆sticas de las Criptomonedas")
|
33 |
+
st.dataframe(df[['coin', 'name', 'price', 'volume', 'algorithm', 'difficulty', 'reward_block']],
|
34 |
+
use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
else:
|
37 |
st.write("Presiona el bot贸n para actualizar los datos.")
|