Skip to main content

Basic syntax

with car as c:
    c.select([c.Name, c.Horsepower], sort=c.Year)
    c.limit(10)
  • SQL
  • Result
  • AST
  • AST graph
from vinyl.operations import coalesce

with birdstrikes as b:
    b.filter(b.Effect__Amount_of_damage == None)
    b.filter(b.Airport__Name != None)
    b.select({"airport_name": coalesce(b.Airport__Name, "Unknown")})
column is None and column is not None will not work as expected because Python requires is statements to evaluate to True or False.
  • SQL
  • Result
  • AST
  • AST graph
def perimeter(x, y):
    return 2 * (x + y)


with iris as i:
    i.define({"petalPerimeter": perimeter(i.petalLength, i.petalWidth)})
  • SQL
  • Result
  • AST
  • AST graph
with co2_concentration as c:
    c.define(
        {"CO2_normalized": c.CO2 - c.CO2.mean()},
        by=[c.Date.dt.extract("month")],
    )
    c.select([c.CO2_normalized], sort=c.Date)
  • SQL
  • Result
  • AST
  • AST graph
with weather as w:
    w.define({"high_vs_expected": w.actual["high"] - w.normal["high"]})
    w.dropna(w.high_vs_expected)
  • SQL
  • Result
  • AST
  • AST graph
import re

with budget as b:
    b.unpivot(
        [col for col in b.columns if re.match(r"\d{4}", col)], 
        colnames_to = "year", 
        colnames_transform = int, 
        values_to= "budget"
    )
  • SQL
  • Result
  • AST
  • AST graph
with barley as b:
    b.pivot(colnames_from="year", values_from="yield")
  • SQL
  • Result
  • AST
  • AST graph