Skip to content

Introduction

Method Chaining

Equivalent to .pipe() in Pandas

df = (
  df
  .with_columns(f) # single function
  .with_columns([g1, g2]) # multiple functions concurrently
)

def f() -> pl.Expr:
    """
    Get first word of column
    "Chicago" -> "C"
    """
    cols = ["City", "Country"]
    return pl.col(cols).str.get(0)
Last Updated: 2024-12-26 ; Contributors: AhmedThahir, web-flow

Comments