python - Writing Percentages in Excel Using Pandas -
when writing csv's before using pandas, use following format percentages:
'%0.2f%%' % (x * 100)
this processed excel correctly when loading csv.
now, i'm trying use pandas' to_excel function , using
(simulated * 100.).to_excel(writer, 'simulated', float_format='%0.2f%%')
and getting "valueerror: invalid literal float(): 0.0126%". without '%%' writes fine not formatted percent.
is there way write percentages in pandas' to_excel?
you can following workaround in order accomplish this:
df *= 100 df = pandas.dataframe(df, dtype=str) df += '%' ew = pandas.excelwriter('test.xlsx') df.to_excel(ew) ew.save()
Comments
Post a Comment