Getting 'ValueError'

Discussion in 'Python' started by Vishal Singh, 17 Aug 2023.

  1. Vishal Singh

    Vishal Singh New Member

    Joined:
    8 Aug 2023
    Messages:
    10
    Likes Received:
    0
    Reputations:
    0
    Input contains NaN, infinity or a value too large for dtype('float64')' when trying to perform a groupby operation on my DataFrame. Here's my code snippet:

    Code:
    import pandas as pd
    
    # Load data from CSV
    data = pd.read_csv('data.csv')
    
    # Perform groupby operation
    grouped = data.groupby('category')['value'].sum()
    
    I've checked for NaN or infinity values in 'value' column using data['value'].isnull().sum() and data['value'].isinf().sum() which both returned 0. What could be causing this error and how can I resolve it?