• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / pandas min – Find Minimum Value of Series or DataFrame

pandas min – Find Minimum Value of Series or DataFrame

December 20, 2021 Leave a Comment

To find the minimum value of a column in pandas, the easiest way is to use the pandas min() function.

df["Column"].min()

You can also use the numpy min() function.

np.min(df["Column"])

Finding the minimum value of numbers in a column, or the minimum value of all numbers in a DataFrame using pandas is easy. We can use the pandas min() function to find the minimum values in a column of numbers, or a DataFrame.

Let’s say we have the following DataFrame.

df = pd.DataFrame({'Name': ['Jim', 'Sally', 'Bob', 'Sue', 'Jill', 'Larry'],
                   'Weight': [160.20, 123.81, 209.45, 150.35, 102.43, 187.52]})

print(df)
# Output: 
    Name  Weight
0    Jim  160.20
1  Sally  123.81
2    Bob  209.45
3    Sue  150.35
4   Jill  102.43
5  Larry  187.52

To get the minimum value of the numbers in the column “Weight”, we can use the pandas min() function in the following Python code:

print(df["Weight"].min())

# Output:
102.43

Please note, you can use the pandas min() function on an entire DataFrame if the DataFrame only contains numbers. If we call it on the DataFrame from above, we will receive an error because the “Name” column is made up of strings.

Using numpy min to Calculate Minimum Value in pandas DataFrame

We can also use the numpy min() function to calculate the minimum value of the numbers in a column in a pandas DataFrame.

To get the minimum value of the numbers in the column “Weight”, we can use the numpy min() function in the following Python code:

print(np.min(df["Weight"]))

# Output:
102.43

As you can see above, this is the same value we received from the pandas min() function.

If you are looking to find the minimum value of a set of numbers in regular Python, you can use the python min() function.

If on the other hand you are looking to find the maximum value of a set of numbers, you can use the pandas max() function.

Hopefully this article has been helpful for you to understand how to find the minimum value of numbers in a Series or DataFrame in pandas.

Other Articles You'll Also Like:

  • 1.  Python Factorial Recursion – Using Recursive Function to Find Factorials
  • 2.  How to Find the Longest String in List in Python
  • 3.  pandas floor – Find the Floor of a Column Using Numpy floor
  • 4.  How to Check if List is Empty in Python
  • 5.  pandas cumsum – Find Cumulative Sum of Series or DataFrame
  • 6.  How to Hide Turtle in Python with hideturtle() Function
  • 7.  Run Something Every 5 Seconds in Python
  • 8.  What Curly Brackets Used for in Python
  • 9.  Remove None From List Using Python
  • 10.  How to Add Commas to Numbers in Python

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy