How to compute the cumulative maximum with Pandas using Python
• 1 minA cumulative maximum is often used when you want to know what was the maximum value at that point in time from the beginning.
It checks what has been the maximum value so far since we started counting.
Here is an example
import pandas as pd
# We create a
df = pd.DataFrame({"col1" : [2, 1, 4, 2, 0]})
# We compute and print the cummulative maximum
print(df["col1"].cummax())
Here you are! You now know how to compute the cumulative maximum with Pandas using Python.
More on DataFrames
If you want to know more about DataFrame and Pandas. Checkout the other articles I wrote on the topic, just here :
Pandas - The Python You Need
We gathered the only Python essentials that you will probably ever need.