URL#
- class polars_extensions.url.UrlExtensionNamespace(expr: Expr)[source]#
Bases:
objectMethods
domain()Extract just the domain name (without port or subdomain).
fragment()Extract fragment (#section).
host()Extract host (domain + optional port).
path()Extract the path (/docs/, /path/to/page, etc.).
query()Extract the full query string.
query_param(key)Extract the value of a specific query parameter.
scheme()Extract URL scheme (http, https, ftp, etc.).
- query() Expr[source]#
Extract the full query string.
Examples
import polars as pl import polars_extensions as plx df = pl.DataFrame({ "link": [ "https://pypi.org/search/?q=polars-extensions", "https://pypi.org/search/?q=polars", "https://pypi.org/search/?q=pyodbc" ] }) df.with_columns(pl.col('link').url_ext.query().alias('q'))
shape: (3, 2) ┌─────────────────────────────────┬─────────────────────┐ │ link ┆ q │ │ --- ┆ --- │ │ str ┆ str │ ╞═════════════════════════════════╪═════════════════════╡ │ https://pypi.org/search/?q=pol… ┆ q=polars-extensions │ │ https://pypi.org/search/?q=pol… ┆ q=polars │ │ https://pypi.org/search/?q=pyo… ┆ q=pyodbc │ └─────────────────────────────────┴─────────────────────┘
- query_param(key: str) Expr[source]#
Extract the value of a specific query parameter.
Examples
import polars as pl import polars_extensions as plx df = pl.DataFrame({ "link": [ "https://pypi.org/search/?q=polars-extensions", "https://pypi.org/search/?q=polars", "https://pypi.org/search/?q=pyodbc" ] }) df.with_columns(pl.col('link').url_ext.query_param('q').alias('q'))
shape: (3, 2) ┌─────────────────────────────────┬───────────────────┐ │ link ┆ q │ │ --- ┆ --- │ │ str ┆ str │ ╞═════════════════════════════════╪═══════════════════╡ │ https://pypi.org/search/?q=pol… ┆ polars-extensions │ │ https://pypi.org/search/?q=pol… ┆ polars │ │ https://pypi.org/search/?q=pyo… ┆ pyodbc │ └─────────────────────────────────┴───────────────────┘