perRowCol

inline fun <T, C, reified R> Convert<T, C>.perRowCol(infer: Infer = Infer.Nulls, noinline expression: RowColumnExpression<T, C, R>): DataFrame<T>

Converts values in the columns previously selected with convert using row column expression within the DataFrame.

A row column expression allows you to provide a new value for every selected cell given its row and column (as lambda arguments).

For more information: See convert on the documentation website.

See Also

  • Convert with to provide a new value for every selected cell giving its row and its previous value.

  • Convert as column to convert using a column converter

Example:

// Convert values in all columns to `String` and add their column name to the end
df.convert { all() }.perRowCol { row, col ->
col[row].toString() + col.name()
}

Parameters

infer

Infer strategy that defines how the type of the resulting column should be determined. Defaults to Infer.Nulls.

expression

The RowColumnExpression to provide a new value for every selected cell giving its row and column.


Creates a new FormattedFrame that uses the specified RowColFormatter to format the selected cells of the dataframe.

You need to specify formatter: A lambda function expecting a CellAttributes or null given an instance of DataRow<T> and ColumnWithPath<C>.

This is similar to a RowColumnExpression, except that you also have access to the FormattingDsl in the context.

The formatting DSL allows you to create and combine CellAttributes to apply to one or multiple cells of a dataframe such that they have specific CSS attributes applied to them when rendered to HTML.

For instance, to specify black, bold text on a white background, you could write:

background(white) and textColor(black) and bold

It's also possible to define your own colors using rgb or interpolate colors using linear.

Use attr if you want to specify a custom CSS attribute.

For more information: See format on the documentation website.

Examples using perRowCol:

df.format { colsOf<Int>() }.perRowCol { row, col ->
linearBg(col[row], col.min() to red, col.max() to green)
}

Check out the full Grammar.


inline fun <T, C> Update<T, C>.perRowCol(crossinline expression: RowColumnExpression<T, C, C>): DataFrame<T>

Per Row Col

Provide a new value for every selected cell given both its row and column using a row-column expression.

For example:

df.update{ age }.perRowCol{ row, col ->

    row.age / col.mean(skipNA = true)

}

For more information: See update on the documentation website.

See Also

  • Update with to provide a new value for every selected cell giving its row and its previous value.

  • Update per col to provide a new value for every selected cell giving its column.

Parameters

expression

The Row Column Expression to provide a new value for every selected cell giving its row and column.