Spaces:
Sleeping
Sleeping
| import marimo | |
| __generated_with = "0.9.18" | |
| app = marimo.App(width="full") | |
| 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,) | |
| def __(mo): | |
| mo.md(r"""## Select a dataset""") | |
| return | |
| 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 | |
| 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,) | |
| def __(mo): | |
| mo.md(r"""## Summary""") | |
| return | |
| def __(explore, mo): | |
| _schema = mo.accordion({"Schema": explore.schema}) | |
| mo.md(f""" | |
| * Total rows: **{len(explore):,}** | |
| * Total columns: **{len(explore.columns)}** | |
| {_schema} | |
| """) | |
| return | |
| def __(explore): | |
| explore.describe() | |
| return | |
| def __(mo): | |
| mo.md("""## Manipulate the data""") | |
| return | |
| def __(explore, mo): | |
| transformed = mo.ui.dataframe(explore) | |
| transformed | |
| return (transformed,) | |
| def __(mo): | |
| mo.md(r"""## Explore the data""") | |
| return | |
| def __(mo, transformed): | |
| mo.ui.data_explorer(transformed.value) | |
| return | |
| def __(): | |
| # Imports | |
| import marimo as mo | |
| import polars | |
| return mo, polars | |
| if __name__ == "__main__": | |
| app.run() | |