Spaces:
Build error
Build error
Download app.py from jbenavidesv87/mcd_bigdata: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/spaces/jbenavidesv87/mcd_bigdata/resolve/main/app.py
- Command line
-
hf download hf://spaces/jbenavidesv87/mcd_bigdata/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jbenavidesv87/mcd_bigdata/resolve/main/app.py
1.88 kB
| import streamlit as st | |
| st.title('MCD | BigData') | |
| st.write('Primera aplicación web con Streamlit y HuggingFace') | |
| tab1, tab2 = st.tabs(["PySpark", "General"]) | |
| with tab1: | |
| from pyspark.sql import SparkSession | |
| spark = SparkSession.builder \ | |
| .appName('ml') \ | |
| .getOrCreate() | |
| archivo = st.file_uploader("Sube tu archivo", type = ['txt', 'csv']) | |
| if archivo is not None: | |
| texto = archivo.read().decode("utf-8") | |
| if texto: | |
| st.write(texto) | |
| with tab2: | |
| ''' | |
| # Este es un encabezado de nivel 1 | |
| ## Este es uno de nivel 2 | |
| Y podemos usar _cursivas_, *negritas*, [vínculos](google.com)... | |
| ''' | |
| # Entrada de texto | |
| nombre = st.text_input('Escribe tu nombre') | |
| # Barra deslizante | |
| nacimiento = st.slider('¿En qué año naciste?', 1940, 2024, help = 'Desliza el selector hasta tu año de nacimiento') | |
| if 2024 - nacimiento > 18: | |
| st.write(f'Eres mayor de edad y al terminar este año deberías tener {2024 - nacimiento} años 🥳') | |
| saludo = '' | |
| # Botón | |
| if len(nombre) > 0: | |
| if st.button('Di hola'): | |
| saludo = f'¡Hola {nombre}!' | |
| if st.button('Borrar saludo'): | |
| saludo = '' | |
| st.write(saludo) | |
| # Select o combobox | |
| color = st.selectbox('Elige tu color favorito', | |
| ['rojo', 'verde', 'azul'], | |
| index = None, | |
| placeholder = 'Color...' | |
| ) | |
| if color != None: | |
| st.write(f'Tu color favorito es {color}') | |
| import pandas as pd | |
| df = pd.DataFrame({ | |
| 'numeros' : [1, 2, 3, 4], | |
| 'letras' : ['a', 'b', 'c', 'd'] | |
| }) | |
| st.write(df) | |
| import matplotlib.pyplot as plt | |
| fig = plt.figure() | |
| plt.scatter(df.numeros, df.letras) | |
| st.pyplot(fig) |