File size: 2,021 Bytes
10db5b3 |
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 |
import marimo
__generated_with = "0.9.18"
app = marimo.App(width="full")
@app.cell
def __():
datasets = [
# Add your own HF datasets
"scikit-learn/iris/Iris.csv",
"scikit-learn/adult-census-income/adult.csv",
"scikit-learn/auto-mpg/auto-mpg.csv",
"scikit-learn/credit-card-clients/UCI_Credit_Card.csv",
"scikit-learn/Fish/Fish.csv",
"scikit-learn/tips/tips.csv",
]
return (datasets,)
@app.cell(hide_code=True)
def __(mo):
mo.md(r"""## Select a dataset""")
return
@app.cell(hide_code=True)
def __(datasets, mo):
dataset = mo.ui.dropdown(datasets, value=datasets[0], label="Select a dataset")
no_limit = mo.ui.switch(label="Limit 1000", value=True)
mo.hstack([dataset, no_limit])
return dataset, no_limit
@app.cell
def __(dataset, mo, no_limit):
explore = mo.sql(
f"""
CREATE OR REPLACE TEMP TABLE explore
AS (FROM 'hf://datasets/{dataset.value}')
{'LIMIT 1000' if no_limit.value else ''};
FROM explore;
"""
)
return (explore,)
@app.cell(hide_code=True)
def __(mo):
mo.md(r"""## Summary""")
return
@app.cell(hide_code=True)
def __(explore, mo):
_schema = mo.accordion({"Schema": explore.schema})
mo.md(f"""
* Total rows: **{len(explore):,}**
* Total columns: **{len(explore.columns)}**
{_schema}
""")
return
@app.cell
def __(explore):
explore.describe()
return
@app.cell(hide_code=True)
def __(mo):
mo.md("""## Manipulate the data""")
return
@app.cell
def __(explore, mo):
transformed = mo.ui.dataframe(explore)
transformed
return (transformed,)
@app.cell(hide_code=True)
def __(mo):
mo.md(r"""## Explore the data""")
return
@app.cell
def __(mo, transformed):
mo.ui.data_explorer(transformed.value)
return
@app.cell(hide_code=True)
def __():
# Imports
import marimo as mo
import polars
return mo, polars
if __name__ == "__main__":
app.run()
|