Skip to content

DOC: Add examples for float_format in to_csv documentation #60363

@felicijo

Description

@felicijo

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html

Documentation problem

The float_format parameter in to_csv is explained but lacks examples. Users might struggle to understand how to apply this parameter effectively without concrete examples in the documentation.

Suggested fix for documentation

I suggest adding examples for float_format to make the documentation more beginner-friendly. Examples could include:

# Format floats to two decimal places
df.to_csv("example1.csv", float_format="%.2f")

# Use scientific notation
df.to_csv("example2.csv", float_format="{:.2e}".format)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions