Spaces:
Runtime error
Runtime error
File size: 2,182 Bytes
7316ecd effce00 7316ecd effce00 7316ecd effce00 |
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 |
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'<a href="data:file/csv;base64,{b64}" download="{csv_filename}">Download example data</a>'
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) |