A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11553 below:

DataFrame.to_csv ignores some formatting parameters for float indexes · Issue #11553 · pandas-dev/pandas · GitHub

Skip to content Navigation Menu

Saved searches Use saved searches to filter your results more quickly

Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert Additional navigation options

DataFrame.to_csv ignores some formatting parameters for float indexes #11553

Description

xref #11551

Parameter float_format and decimal options are ignored in an Index, but work in the data itself.

In [2]: pd.DataFrame({'a': [0.1,1.1], 'b': [2, 3]}).to_csv(float_format='%.2f', index=False)
Out[2]: 'a,b\n0.10,2\n1.10,3\n

In [3]: pd.DataFrame({'a': [0.1,1.1], 'b': [2, 3]}).set_index('a').to_csv(float_format='%.2f')
Out[3]: 'a,b\n0.1,2\n1.1,3\n'

and

In [4]: pd.DataFrame({'a': [0.1,1.1], 'b': [2, 3]}).to_csv(decimal='^', index=False)
Out[4]: 'a,b\n0^1,2\n1^1,3\n'

In [4]: pd.DataFrame({'a': [0.1,1.1], 'b': [2, 3]}).set_index('a').to_csv(decimal='^')
Out[4]: 'a,b\n0.1,2\n1.1,3\n'

I'll do a PR, soon I hope :)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4