snowflake.snowpark.DataFrame.col

DataFrame.col(col_name: str) → Column[source]

Returns a reference to a column in the DataFrame.

Use the returned Column expression in operations such as select() and filter(). This method doesn’t retrieve the column’s values; call an action such as collect() on the resulting DataFrame to retrieve rows.

Parameters:

col_name – The name of a column in this DataFrame, or "*" to reference all columns.

Examples:

>>> df = session.create_dataframe([(1, 10), (2, 20)], schema=["id", "amount"])
>>> df.select(df.col("id"), (df.col("amount") + 5).alias("adjusted")).sort("id").collect()
[Row(ID=1, ADJUSTED=15), Row(ID=2, ADJUSTED=25)]
>>> df.filter(df.col("amount") > 10).select(df.col("id")).collect()
[Row(ID=2)]