Friday, June 12, 2026
HomeLanguagesPython | Pandas dataframe.cummin()

Python | Pandas dataframe.cummin()

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Pandas dataframe.cummin() is used to find the cumulative minimum value over any axis. Each cell is populated with the minimum value seen so far.

Syntax: DataFrame.cummin(axis=None, skipna=True, *args, **kwargs)

Parameters:
axis : {index (0), columns (1)}
skipna : Exclude NA/null values. If an entire row/column is NA, the result will be NA

Returns: cummin : Series

Example #1: Use cummin() function to find the cumulative minimum value along the index axis.




# importing pandas as pd
import pandas as pd
  
# Creating the dataframe
df = pd.DataFrame({"A":[5, 3, 6, 4],
                   "B":[11, 2, 4, 3],
                   "C":[4, 3, 8, 5],
                   "D":[5, 4, 2, 8]})
  
# Print the dataframe
df


Output :

Now find the cumulative minimum value over the index axis




# To find the cumulative min
df.cummin(axis = 0)


Output :

 

Example #2: Use cummin() function to find the cumulative minimum value along the column axis.




# importing pandas as pd
import pandas as pd
  
# Creating the dataframe
df = pd.DataFrame({"A":[5, 3, 6, 4], 
                   "B":[11, 2, 4, 3],
                   "C":[4, 3, 8, 5],
                   "D":[5, 4, 2, 8]})
  
# To find the cumulative min along column axis
df.cummin(axis = 1)


Output :

 

Example #3: Use cummin() function to find the cumulative minimum value along the index axis in a data frame with NaN value.




# importing pandas as pd
import pandas as pd
  
# Creating the dataframe
df = pd.DataFrame({"A":[5, 3, None, 4],
                   "B":[None, 2, 4, 3],
                   "C":[4, 3, 8, 5], 
                   "D":[5, 4, 2, None]})
  
# To find the cumulative min
df.cummin(axis = 0, skipna = True)


Output :

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS