I try to use panda df[].astype(float).describe But, there is a problem. My data type is like$8,120,000,000 So, how to convert to 8120000000? it shows
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-177-5ee173ce9990> in <module>()
----> 1 df['Revenue'].astype(float).describe()
4 frames /usr/local/lib/python3.6/dist-packages/pandas/core/dtypes/cast.py in astype_nansafe(arr, dtype, copy, skipna)
988 if copy or is_object_dtype(arr) or is_object_dtype(dtype):
989 # Explicit copy, or required since NumPy can't view from / to object.
--> 990 return arr.astype(dtype, copy=True)
991
992 return arr.view(dtype)
ValueError: could not convert string to float: '$8,120,000,000'
I tried to use replace to change the list
revenue_list = [item.replace("$", "") for item in revenue_list]
revenue_list = [item.replace(",", "") for item in revenue_list]
print(revenue_list)
But, it still doesn't work