Instagram
youtube
Facebook
Twitter

Compute the Maximum Value of a Column in a Pandas DataFrame

A Compute the Maximum Value of a Column in a Pandas DataFrame

Short Description of the Program:
This program finds the maximum value in the 'Age' column using Pandas’ .max() function.

Explanation:

  • df['Age'] accesses the Age column of the DataFrame.
     
  • .max() retur
    import pandas as pd
    
    data = {
    
        'Name': ['Alice', 'Bob', 'Charlie', 'Diana', 'Eva', 'Frank'],
    
        'Age': [25, 30, 22, 28, 26, 35],
    
        'Gender': ['Female', 'Male', 'Male', 'Female', 'Female', 'Male'],
    
        'City': ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Seattle']
    }
    df = pd.DataFrame(data)
    
    max_age = df['Age'].max()
    
    print("Maximum Age:", max_age)
    ns the largest value from that column.
     
  • Useful for determining the oldest person or peak value in a dataset.
     

Program: