79291834

Date: 2024-12-18 16:41:46
Score: 1
Natty:
Report link

It is likely that there are non-numeric values in the 'Gross' column. Inspect the columns for conformity of data type.

Check for Empty Strings or Fully Non-Numeric Rows

print(read[read['Gross'].isnull()])

Remove leading/trailing spaces

read['Gross'] = read['Gross'].str.strip() read['Gross'] = read['Gross'].str.replace('[^\d.]', '', regex=True)

Once cleaned, try the conversion again:

read['Gross'] = pd.to_numeric(read['Gross'], errors='coerce')

Fill missing values with 0

read['Gross'].fillna(0, inplace=True)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: carik