Now using nucsit026's answer to create a slightly different dataFrame with strings
dic = {'revenue':['7980.79',np.nan,'1000.25','17800.85','None','2457.85','6789.33']}
print(df)
print(df['revenue'].dtypes
Output:
revenue
0 7980.79
1 NaN
2 1000.25
3 17800.85
4 None
5 2457.85
6 6789.33
dtype('O')
try this:
df['revenue']=pd.to_numeric(data['revenue'], errors='coerce').fillna(0, downcast='infer')
it will replace nan with 0s
Output:
0 7980.79
1 0.00
2 1000.25
3 17800.85
4 0.00
5 2457.85
6 6789.33
Name: revenue, dtype: float64
EDIT:
From your shared error if quotes are the problem you can use
df['revenue']=df['revenue'].str.strip("'")
and then try to convert to float using above mentioned code
EDIT2
OP had some spaces in the column values like this
Month Revenue
Apr-13 16 004 258.24
May-13
Jun-13 16 469 157.71
Jul-13 19 054 861.01
Aug-13 20 021 803.71
Sep-13 21 285 537.45
Oct-13 22 193 453.80
Nov-13 21 862 298.20
Dec-13 10 053 557.64
Jan-14 17 358 063.34
Feb-14 19 469 161.04
Mar-14 22 567 078.21
Apr-14 20 401 188.64
In this case use following code:
df['revenue']=df['revenue'].replace(' ', '', regex=True)
and then perform the conversion