datatable.min()

Calculate the minimum value for each column from cols. It is recommended to use it as dt.min() to prevent conflict with the Python built-in min() function.

Parameters

cols
FExpr

Input columns.

return
FExpr

f-expression having one row and the same names, stypes and number of columns as in cols.

except
TypeError

The exception is raised when one of the columns from cols has a non-numeric type.

Examples

from datatable import dt, f, by df = dt.Frame({'A': [1, 1, 1, 2, 2, 2, 3, 3, 3], 'B': [3, 2, 20, 1, 6, 2, 3, 22, 1]}) df
AB
int32int32
013
112
2120
321
426
522
633
7322
831

Get the minimum from column B:

df[:, dt.min(f.B)]
B
int32
01

Get the minimum of all columns:

df[:, [dt.min(f.A), dt.min(f.B)]]
AB
int32int32
011

Same as above, but using the slice notation:

df[:, dt.min(f[:])]
AB
int32int32
011

You can pass in a dictionary with new column names:

df[:, dt.min({"A_min": f.A, "B_min": f.B})]
A_minB_min
int32int32
011

In the presence of by(), it returns the row with the minimum value per group:

df[:, dt.min(f.B), by("A")]
AB
int32int32
012
121
231