Running historical lows
Track the lowest observed value to date separately for each column in ordered records.
Pandas · Module
Returns the cumulative minimum along a DataFrame axis, preserving the input shape. By default it operates down columns, skips missing values, and can optionally restrict processing to numeric and Boolean columns.
DataFrame.cummin() returns a same-shaped object whose values are the running minimum along the selected axis. With the default index axis, each column is evaluated independently; axis=1 instead evaluates values across each row. Missing values are skipped by default, while numeric_only can restrict processing to numeric and Boolean columns.
DataFrame.cummin(axis=0, skipna=True, numeric_only=False, **kwargs)| Name | Type | Description |
|---|---|---|
axis | {0 or 'index', 1 or 'columns'}, default 0 | The index or the name of the axis; 0, None, or 'index' selects the index axis, while 1 or 'columns' selects the columns axis. Default: 0. |
skipna | bool, default True | Whether to exclude missing values. Default: True. |
numeric_only | bool, default False | Whether to include only float, integer, and Boolean columns. Default: False. |
**args, **kwargs | variadic | Additional compatibility arguments accepted by the underlying implementation. |
DataFrame or Series: cumulative minimum of the input DataFrame or Series.
import pandas as pd
df = pd.DataFrame({"A": [2, 3, 1], "B": [1, None, 0]})
print(df.cummin())
print(df.cummin(axis=1))Computes running minima down columns by default, then across each row when axis=1.
Track the lowest observed value to date separately for each column in ordered records.
Find progressively smaller values across fields within each record.
Avoid applying the operation to text or other nonnumeric fields in mixed-type data.
It computes the cumulative minimum along a DataFrame axis and returns a DataFrame of the same size. The default axis is 0, so each column receives its running minimum independently.
Follow-up: What changes with axis=1? Each row is processed from left to right, producing the running minimum across that row instead of down columns.
skipna=True is the default, so missing values are excluded when possible. However, an entirely missing row or column still produces missing output.
Follow-up: What is a practical consequence? A later non-missing value can resume the cumulative calculation after a missing value when skipna remains enabled.
numeric_only=True limits the operation to float, integer, and Boolean columns. The default is False, so the operation is not restricted to those column types.
Follow-up: When would you use it? Use numeric_only when a mixed-type DataFrame should be processed only through its numeric and Boolean columns.
DataFrame.cummaxDataFrame.cumprodDataFrame.cumsumSeries.cummin