using pandas to number and coerce to force values to ints and still not working

  Kiến thức lập trình

Confused when I am trying to coerce dataframe to numeric. It appears to work when I look at structure but then I still get errors:

TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’

Code:

df = df_leads.apply(pd.to_numeric, errors='coerce') code here

df.info()

Returns: Columns: 133 entries, org_size_1_99 to engagement_Type_webpage visits dtypes: float64(107), int64(26) memory usage: 3.1 MB

next line of code:

sum(df['target']).astype(int)

returns: TypeError: unsupported operand type(s) for +: 'int' and 'str'

LEAVE A COMMENT