Path: blob/main/docs/source/src/python/polars-cloud/quickstart.py
8336 views
"""1# --8<-- [start:general]2import polars_cloud as pc3import polars as pl45# First, we need to define the hardware the cluster will run on.6# This can be done by specifying the minimum CPU and memory or7# by specifying the exact instance type in AWS.89ctx = pc.ComputeContext(memory=8, cpus=2, cluster_size=1)1011# Then we write a regular lazy Polars query. In this example12# we compute the maximum of column.1314lf = pl.LazyFrame(15{16"a": [1, 2, 3],17"b": [4, 4, 5],18}19).with_columns(20pl.col("a").max().over("b").alias("c"),21)2223# At this point, the query has not been executed yet.24# We need to call `.remote()` to signal that we want to run25# on Polars Cloud and then `.execute()` send the query and execute it.2627(28lf.remote(context=ctx).execute().await_result()29)3031# We can then wait for the result with `await_result()`.32# The query and compute used will also show up in the33# portal at https://cloud.pola.rs/portal/3435# --8<-- [end:general]36"""373839