np.maximum.reduce(lst) has different behavior from functools.reduce(np.maximum, lst) and also different behavior from np.maximum itself, when one of the elements in the list is a number (e.g. int) instead of an array/pandas Series.
np.maximum.reduce
on one hand,
import pandas as pd
import numpy as np
df = pd.DataFrame({'a': [1, 3, 2]})
np.maximum.reduce([df['a'], 2])
The last line gives the following error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
np.maximum
on the other hand,
np.maximum(df['a'], 2)
yields the expected output
0 2
1 3
2 2
Name: a, dtype: int64
reduce(np.maximum)
on a third hand,
reduce(np.maximum, [df['a'], 2])
also yields the expected output
0 2
1 3
2 2
Name: a, dtype: int64
Versions used
pandas version: 1.2.5
numpy version: 1.19.5
python: 3.7.9