Recipe: How to find the largest value in a Pandas DataFrame?
DATA MUNGING PYTHON PANDAS DATAFRAME PANDAS CHEATSHEET PANDAS DATAFRAME TUTORIAL

How to find the largest value in a Pandas DataFrame?

This recipe helps you find the largest value in a Pandas DataFrame
In [1]:
## How to find the largest value in a Pandas DataFrame
def Kickstarter_Example_88():
    print()
    print(format('How to find the largest value in a Pandas DataFrame','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # load libraries
    import pandas as pd

    # Create dataframe
    raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'],
                'last_name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze'],
                'age': [42, 52, 36, 24, 73],
                'preTestScore': [4, 24, 31, 2, 3],
                'postTestScore': [25, 94, 57, 62, 70]}

    df = pd.DataFrame(raw_data, columns = ['first_name', 'last_name', 'age',
                                           'preTestScore', 'postTestScore'])
    print(); print(df)

    # Index of the row with the highest and  lowest value in the preTestScore column
    print()
    print("Index of highest value: "); print(df['preTestScore'].idxmax())
    print("Index of lowest value: "); print(df['preTestScore'].idxmin())

Kickstarter_Example_88()
***************How to find the largest value in a Pandas DataFrame****************

  first_name last_name  age  preTestScore  postTestScore
0      Jason    Miller   42             4             25
1      Molly  Jacobson   52            24             94
2       Tina       Ali   36            31             57
3       Jake    Milner   24             2             62
4        Amy     Cooze   73             3             70

Index of highest value:
2
Index of lowest value:
3


Stuck at work?
Can't find the recipe you are looking for. Let us know and we will find an expert to create the recipe for you. Click here
Companies using this Recipe
1 developer from Ernst & Young
1 developer from ICU Medical
1 developer from Microsoft
1 developer from Snapptrip.com
1 developer from YASH Technologies
1 developer from Altimetrik
1 developer from Fidelity Investments
1 developer from Infosys
1 developer from MudraCircle
1 developer from Tata Consultancy Services