# datatable.max()¶

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

## Parameters¶

cols
`FExpr`

Input columns.

return
`Expr`

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 maximum from column B:

```df[:, dt.max(f.B)] ```
B
int32
022

Get the maximum of all columns:

```df[:, [dt.max(f.A), dt.max(f.B)]] ```
AB
int32int32
0322

Same as above, but more convenient:

```df[:, dt.max(f[:])] ```
AB
int32int32
0322

You can pass in a dictionary with new column names:

```df[:, dt.max({"A_max": f.A, "B_max": f.B})] ```
A_maxB_max
int32int32
0322

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

```df[:, dt.max(f.B), by("A")] ```
AB
int32int32
0120
126
2322