ColumnDefinition
class ColumnDefinition(name: str | None = None, dtype: ColumnDataType = String)
Categories: projection, string
The column one Grok capture produces: its name and data type.
One of these per capture makes up the schema passed to
TableFrame.grok, keyed by capture name. The captured text is parsed
into dtype; a row that does not match leaves the column null.
Examples
tf.grok(
"logs",
r"%{WORD:user}-%{INT:year}",
{
"user": ColumnDefinition("user", String),
"year": ColumnDefinition("year", Int64),
},
)
A name that differs from the capture renames the column it
produces -- here the user capture lands in a column called
who:
tf.grok(
"logs",
r"%{WORD:user}-.*",
{"user": ColumnDefinition("who", String)},
)
Parameters
parameter
namestr | NoneName of the column to add. None (the default) keeps the
capture's own name, and any other value renames it.
parameter
dtypeColumnDataType (DataType | DataTypeClass)