I am using group by function of pandas, instead of adding numbers, pandas think it is a string and return like: 3,000,000,000.0092,315,000.00 instead of 3,092,315,000. i have tried several methods of conversions but each time it returns "ValueError: could not convert string to float: '3,000,000,000.00'" i am unable to attach csv file, that might be the real problem.
df['AMOUNT'] = df['AMOUNT'].astype('float')
CodePudding user response:
Try to replace ,
with `` first.
df['AMOUNT'] = df['AMOUNT'].str.replace(',', '').astype('float')