I have a dataframe and I need to format one column to $xxx.xx. When I export to excel I need the numbers in float format but they are strings. How to export them as float?
df = pd.DataFrame(index=['index1', 'index2', 'index3'],
columns=["A", "B", "C"],
data=[[5,34, "ok"], [7,8,"fine"], ["3rd",100,np.nan]])
df['B'] = (df['B']).apply(lambda x: '${:,.2f}'.format(x))
df
The exported excel has B column in string format:
What I need: