A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
chore: use polars instead of pandas in examples (#3289)
Akshay Agrawal7ae245de4b85
diff --git a/examples/sql/connect_to_motherduck.py b/examples/sql/connect_to_motherduck.pyindex e5d777e0d3..6b7498d115 100644--- a/examples/sql/connect_to_motherduck.py+++ b/examples/sql/connect_to_motherduck.py@@ -3,8 +3,9 @@# dependencies = [# "altair==5.4.1",# "duckdb==1.1.0",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "marimo",-# "pandas==2.2.3",# ]# ///diff --git a/examples/sql/connect_to_postgres.py b/examples/sql/connect_to_postgres.pyindex 13520413a5..e44ed68125 100644--- a/examples/sql/connect_to_postgres.py+++ b/examples/sql/connect_to_postgres.py@@ -3,7 +3,8 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "requests==2.32.3",# ]# ///diff --git a/examples/sql/connect_to_sqlite.py b/examples/sql/connect_to_sqlite.pyindex 5e20883d6e..a6ca6cebe4 100644--- a/examples/sql/connect_to_sqlite.py+++ b/examples/sql/connect_to_sqlite.py@@ -3,19 +3,20 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "requests==2.32.3",# ]# ///import marimo-__generated_with = "0.9.1"+__generated_with = "0.10.7"app = marimo.App(width="medium")@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""# Connect to SQLite@@ -31,7 +32,7 @@ def __(mo):@app.cell(hide_code=True)-def __():+def _():import marimo as mo@@ -53,7 +54,7 @@ def __():@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: Creating SQL Cells": mo.md(@@ -73,7 +74,7 @@ def __(mo):@app.cell-def __(INFORMATION_SCHEMA, mo):+def _(INFORMATION_SCHEMA, TABLES, mo):_df = mo.sql(f"""-- Boilerplate: detach the database so this cell works when you re-run it@@ -90,13 +91,13 @@ def __(INFORMATION_SCHEMA, mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""Once the database is attached, you can query it with SQL. For example, the next cell computes the average track length of each composer in the chinook database.""")return@app.cell-def __(chinook, mo, track):+def _(chinook, mo, track):_df = mo.sql(f"""SELECT composer, MEAN(Milliseconds) as avg_track_ms from chinook.track GROUP BY composer ORDER BY avg_track_ms DESC;@@ -106,7 +107,7 @@ def __(chinook, mo, track):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(f"""You can explore the schemas of all your tables at a glance in the **data sources panel**: clickdiff --git a/examples/sql/misc/database_explorer.py b/examples/sql/misc/database_explorer.pyindex a2bd409f7c..fcc1b544c5 100644--- a/examples/sql/misc/database_explorer.py+++ b/examples/sql/misc/database_explorer.py@@ -3,7 +3,8 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# ]# ///diff --git a/examples/sql/misc/electric_vehicles.py b/examples/sql/misc/electric_vehicles.pyindex d3b450c4b4..a029b1bba5 100644--- a/examples/sql/misc/electric_vehicles.py+++ b/examples/sql/misc/electric_vehicles.py@@ -2,7 +2,10 @@# requires-python = ">=3.9"# dependencies = [# "altair==5.4.1",+# "duckdb==1.1.3",# "marimo",+# "polars==1.18.0",+# "pyarrow==18.1.0",# ]# ///diff --git a/examples/sql/misc/sql_cars.py b/examples/sql/misc/sql_cars.pyindex a185689770..e20565efd0 100644--- a/examples/sql/misc/sql_cars.py+++ b/examples/sql/misc/sql_cars.py@@ -4,7 +4,8 @@# "altair==5.4.1",# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "vega-datasets==0.9.0",# ]# ///@@ -233,11 +234,10 @@ def __(cars, mo, selected_cars):@app.celldef __():import marimo as mo- import pandas as pdimport duckdbimport altair as altfrom vega_datasets import data- return alt, data, duckdb, mo, pd+ return alt, data, duckdb, moif __name__ == "__main__":diff --git a/examples/sql/parametrizing_sql_queries.py b/examples/sql/parametrizing_sql_queries.pyindex 130b6669bf..4900d790bc 100644--- a/examples/sql/parametrizing_sql_queries.py+++ b/examples/sql/parametrizing_sql_queries.py@@ -3,7 +3,8 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "vega-datasets==0.9.0",# ]# ///diff --git a/examples/sql/querying_dataframes.py b/examples/sql/querying_dataframes.pyindex e60055ba31..01c2c2939c 100644--- a/examples/sql/querying_dataframes.py+++ b/examples/sql/querying_dataframes.py@@ -3,7 +3,8 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "vega-datasets==0.9.0",# ]# ///diff --git a/examples/sql/read_csv.py b/examples/sql/read_csv.pyindex 4a81854645..f6d94bf1d3 100644--- a/examples/sql/read_csv.py+++ b/examples/sql/read_csv.py@@ -3,19 +3,20 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "vega-datasets==0.9.0",# ]# ///import marimo-__generated_with = "0.9.1"+__generated_with = "0.10.7"app = marimo.App(width="medium")@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""# Read CSV@@ -27,22 +28,22 @@ def __(mo):@app.cell(hide_code=True)-def __():+def _():import marimo as mo- import pandas as pd+ import polars as pl- pd.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]}).to_csv("data.csv")- return mo, pd+ pl.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]}).write_csv("data.csv")+ return mo, pl@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""Reading from a local CSV is as easy as `SELECT * from "data.csv"`, where `data.csv` is the path to your local file (or a URL to a CSV file).""")return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: Creating SQL Cells": mo.md(@@ -62,19 +63,20 @@ def __(mo):@app.cell-def __(data, mo):+def _(mo):result = mo.sql(f"""-- Tip: you can also specify the data files using a glob, such as '/path/to/*.csv'-- or '/path/**/to/*.csv'SELECT * FROM "data.csv"- """, output=False+ """,+ output=False,)return (result,)@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: Query output": mo.md(@@ -92,13 +94,13 @@ def __(mo):@app.cell-def __(result):+def _(result):resultreturn@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Create an in-memory table from a CSV file@@ -110,7 +112,7 @@ def __(mo):@app.cell-def __(data, mo):+def _(mo):_df = mo.sql(f"""CREATE TABLE myTable AS SELECT * FROM "data.csv"@@ -120,7 +122,7 @@ def __(data, mo):@app.cell-def __(mo, myTable):+def _(mo, myTable):_df = mo.sql(f"""SELECT * FROM myTable@@ -130,13 +132,13 @@ def __(mo, myTable):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Advanced usage""")return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""To customize how your CSV is read, including specifying the delimiter type, use [duckdb's `read_csv` function](https://duckdb.org/docs/data/csv/overview.html).""")returndiff --git a/examples/sql/read_json.py b/examples/sql/read_json.pyindex 13f7be1377..9162672ad7 100644--- a/examples/sql/read_json.py+++ b/examples/sql/read_json.py@@ -3,20 +3,20 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",-# "pyarrow==17.0.0",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "vega-datasets==0.9.0",# ]# ///import marimo-__generated_with = "0.9.1"+__generated_with = "0.10.7"app = marimo.App(width="medium")@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""# Read JSON@@ -28,16 +28,16 @@ def __(mo):@app.cell(hide_code=True)-def __():+def _():import marimo as mo- import pandas as pd+ import polars as pl- pd.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]}).to_json("data.json", orient="records")- return mo, pd+ pl.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]}).write_json("data.json")+ return mo, pl@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""Reading from a JSON file is as easy as@@ -53,7 +53,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: Creating SQL Cells": mo.md(@@ -73,19 +73,20 @@ def __(mo):@app.cell-def __(data, mo):+def _(mo):result = mo.sql(f"""-- Tip: you can also specify the data files using a glob, such as '/path/to/*.json'-- or '/path/**/to/*.json'SELECT * FROM 'data.json'- """, output=False+ """,+ output=False,)return (result,)@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: Query output": mo.md(@@ -103,13 +104,13 @@ def __(mo):@app.cell-def __(result):+def _(result):resultreturn@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Create an in-memory table from a JSON file@@ -121,7 +122,7 @@ def __(mo):@app.cell-def __(data, mo):+def _(mo):_df = mo.sql(f"""CREATE OR REPLACE TABLE myTable AS SELECT * FROM 'data.json'@@ -131,7 +132,7 @@ def __(data, mo):@app.cell-def __(mo, myTable):+def _(mo, myTable):_df = mo.sql(f"""SELECT * FROM myTable@@ -141,13 +142,13 @@ def __(mo, myTable):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Advanced usage""")return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""To customize how your json file is read, use [duckdb's `read_json` function](https://duckdb.org/docs/data/json/overview.html).""")returndiff --git a/examples/sql/read_parquet.py b/examples/sql/read_parquet.pyindex a39cb211d5..3f7da99961 100644--- a/examples/sql/read_parquet.py+++ b/examples/sql/read_parquet.py@@ -3,8 +3,8 @@# dependencies = [# "duckdb==1.1.1",# "marimo",-# "pandas==2.2.3",-# "pyarrow==17.0.0",+# "polars==1.18.0",+# "pyarrow==18.1.0",# "vega-datasets==0.9.0",# ]# ///@@ -30,10 +30,10 @@ def __(mo):@app.cell(hide_code=True)def __():import marimo as mo- import pandas as pd+ import polars as pl- pd.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]}).to_parquet("data.parquet")- return mo, pd+ pl.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]}).write_parquet("data.parquet")+ return mo, pl@app.cell(hide_code=True)