import streamlit as st import pandas as pd from pandas_profiling import ProfileReport import base64 st.set_page_config(page_title="Data Browser", page_icon=":bar_chart:") st.title("Data Browser") # File upload st.header("Upload your data file") uploaded_file = st.file_uploader("", type=["csv", "xlsx"]) if uploaded_file is not None: # Determine file type file_ext = uploaded_file.name.split(".")[-1] if file_ext == "csv": df = pd.read_csv(uploaded_file) elif file_ext in ["xls", "xlsx"]: df = pd.read_excel(uploaded_file) # Display basic info st.write(f"Number of rows: {df.shape[0]}") st.write(f"Number of columns: {df.shape[1]}") st.write("Sample data:") st.dataframe(df.head()) # Generate pandas profiling report report = ProfileReport(df, explorative=True) st.header("Data profiling") st.write("Data distribution:") #st.markdown(report) # Display report: report.to_file("./index.html") path_or_fileobj ="./index.html" # Streamlit magic: report # Download link for example data example_csv = """name,age,income Alice,25,50000 Bob,30,70000 Charlie,35,90000""" csv_filename = "example.csv" b64 = base64.b64encode(example_csv.encode()).decode() href = f'Download example data' st.markdown(href, unsafe_allow_html=True) # HuggingFace Hub Demo - Model Cards from Template from pathlib import Path from huggingface_hub import ModelCard, ModelCardData # Define your jinja template template_text = """ --- {{ card_data }} --- # Model Card for MyCoolModel This model does this and that. This model was created by [@{{ author }}](https://hf.co/{{author}}). """.strip() # Write the template to a file Path('custom_template.md').write_text(template_text) # Define card metadata card_data = ModelCardData(language='en', license='mit', library_name='keras') # Create card from template, passing it any jinja template variables you want. # In our case, we'll pass author card = ModelCard.from_template(card_data, template_path='custom_template.md', author='nateraw') card.save('my_model_card_1.md') print(card)