EXPAND ALL
  • Home

DataFrame.map

Sets up the runtime expression and assigns the result to the specified column.

Adds a column with the specified name and the expression that evaluates to the column value. The evaluation of this expression happens inside of the Pixie engine (Carnot) thus cannot be directly accessed during compilation. The expression can be a scalar value, a column from the same dataframe, or a UDF function call. The syntax can be either df['colname'] = expr or df.colname = expr, the second option is simply syntactic sugar. The first form is slightly more expressive as you can set column names with spaces.

Arguments

NameTypeDescription
column_namestrThe name of the column to assign this value.
exprScalarExpressionThe expression to evaluate in Carnot.

Returns

px.DataFrame: DataFrame with the new column added.

Examples

df = px.DataFrame('process_stats')
# Map scalar value to a column.
df['number'] = 12
df = px.DataFrame('http_events')
df.svc = df.ctx['svc']
# Map column to another column name.
df.resp_body = df.resp_body
df = px.DataFrame('http_events')
# Map expression to the column.
df['latency_ms'] = df['resp_latency_ns'] / 1.0e9

This site uses cookies to provide you with a better user experience. By using Pixie, you consent to our use of cookies.