Skip to content

DOC: Add examples for float_format in to_csv documentation #60363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
felicijo opened this issue Nov 19, 2024 · 1 comment · Fixed by #60457
Closed
1 task done

DOC: Add examples for float_format in to_csv documentation #60363

felicijo opened this issue Nov 19, 2024 · 1 comment · Fixed by #60457
Assignees
Labels
Docs IO CSV read_csv, to_csv

Comments

@felicijo
Copy link
Contributor

felicijo commented Nov 19, 2024

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)
@felicijo felicijo added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 19, 2024
@mingjji
Copy link

mingjji commented Nov 20, 2024

take

@rhshadrach rhshadrach added IO CSV read_csv, to_csv and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs IO CSV read_csv, to_csv
Projects
None yet
3 participants