Skip to content

Columns and types

Column

wrap classmethod

wrap(c: Column) -> Self

Wrap a column without casting.

to_spark

to_spark() -> Column

group

group() -> Self

Mark column as a group key for use in an aggregate DataFrame constructor.

Example::

class Agg(ts.DataFrame):
    name: ts.String
    total: ts.Int

Agg(df, name=df.name.group(), total=ts.sum(df.age))

The returned value is a _GroupColumn sentinel. Arithmetic and comparison operations on it raise TypeError — operate on the field after construction instead.

cast

cast(dataType: BooleanType) -> Bool
cast(dataType: BinaryType) -> Binary
cast(dataType: DateType) -> Date
cast(dataType: DecimalType) -> Decimal
cast(dataType: DoubleType) -> Double
cast(dataType: FloatType) -> Float
cast(dataType: IntegerType) -> Integer
cast(dataType: LongType) -> Long
cast(dataType: ShortType) -> Short
cast(dataType: StringType) -> String
cast(dataType: TimestampType) -> Timestamp
cast(dataType: TimestampNTZType) -> TimestampNTZ
cast(dataType: ArrayType) -> Array[Any]
cast(dataType: DataType) -> Column[Any]
cast(dataType: U) -> Column[U]

alias

alias(alias: str, **kwargs) -> Self

name

name(alias: str, **kwargs) -> Self

isNull

isNull() -> Bool

isNotNull

isNotNull() -> Bool

like

like(pattern: str) -> Bool

over

over(window: WindowSpec | WindowSpec) -> Self

Evaluate this column over a window, like pyspark.sql.Column.over.

An aggregate (tsf.sum(col).over(w)) becomes a plain column of the same type, so the DataFrame constructor projects it instead of grouping.

desc

desc() -> Self

asc

asc() -> Self

isin

isin(*cols: Any) -> Bool

rlike

rlike(item: str) -> Bool

between

between(lowerBound: Self, upperBound: Self) -> Bool

StringOf

Bases: String

String column restricted to the literal values in T.

Use with Literal, e.g. StringOf[Literal["open", "closed"]]. The restriction is static only; values are not validated at runtime.

isin

isin(*cols: T | StringOf[T] | type[T]) -> Bool

True where the value is in cols. An Enum class expands to all its members.

IntOf

Bases: Integer

Integer column restricted to the literal values in T.

Use with Literal, e.g. IntOf[Literal[1, 2, 3]]. The restriction is static only; values are not validated at runtime. Arithmetic results fall back to plain Integer.

isin

isin(*cols: T | IntOf[T] | type[T]) -> Bool

True where the value is in cols. An Enum class expands to all its members.

Bool

String

Bases: _StringOpsMixin, Column[StringType]

Binary

Bases: _BinaryOpsMixin, Column[BinaryType]

Short

Bases: _IntOpsMixin, Column[ShortType]

Integer

Bases: _IntOpsMixin, Column[IntegerType]

Int module-attribute

Int = Integer

Long

Bases: _IntOpsMixin, Column[LongType]

Float

Bases: _FloatOpsMixin, Column[FloatType]

Double

Bases: _FloatOpsMixin, Column[DoubleType]

Decimal

Bases: _DecimalOpsMixin, Column[DecimalType]

Date

Bases: _DateOpsMixin, Column[DateType]

Timestamp

Bases: _TimestampOpsMixin, Column[TimestampType]

TimestampNTZ

Bases: _TimestampOpsMixin, Column[TimestampNTZType]