Skip to content
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

DOC: Examples added for float_format in to_csv documentation #60457

Merged
merged 10 commits into from
Dec 3, 2024

Conversation

Uvi-12
Copy link
Contributor

@Uvi-12 Uvi-12 commented Dec 1, 2024

Closes #60363

@Uvi-12
Copy link
Contributor Author

Uvi-12 commented Dec 2, 2024

@rhshadrach Please check if the examples are appropriate.

@@ -193,25 +193,25 @@ Visualization

Installable with ``pip install "pandas[plot, output-formatting]"``.

========================= ================== ================== =============================================================
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you undo all the changes in this file? They don't appear related to the linked issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some commits in this PR #60457 were mistakenly added but are meant for issue #60446. I am new to open-source contributions and apologize for the confusion.

Could you please guide me on how I can avoid this mistake in the future?

Comment on lines 3882 to 3886
Format floating-point numbers using float_format:
- Format floats to two decimal places:
>>> df.to_csv("out1.csv", float_format="%.2f") # doctest: +SKIP
- Use scientific notation:
>>> df.to_csv("out2.csv", float_format="{:.2e}".format) # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Format floating-point numbers using float_format:
- Format floats to two decimal places:
>>> df.to_csv("out1.csv", float_format="%.2f") # doctest: +SKIP
- Use scientific notation:
>>> df.to_csv("out2.csv", float_format="{:.2e}".format) # doctest: +SKIP
Format floats to two decimal places:
>>> df.to_csv("out1.csv", float_format="%.2f") # doctest: +SKIP
Format floats using scientific notation:
>>> df.to_csv("out2.csv", float_format="{:.2e}".format) # doctest: +SKIP

@mroeschke mroeschke added the Docs label Dec 2, 2024
@Uvi-12
Copy link
Contributor Author

Uvi-12 commented Dec 2, 2024

@mroeschke The reviewed changes are corrected, have a check and let me know if further changes are required.

@Uvi-12 Uvi-12 requested a review from mroeschke December 3, 2024 04:13
@Uvi-12
Copy link
Contributor Author

Uvi-12 commented Dec 3, 2024

@mroeschke The code is changed accordingly to the reviewed changes, don't know why the tests are failing, can you please help me with it?


Format floats using scientific notation:

>>> df.to_csv("out2.csv", float_format="{:.2e}".format) # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> df.to_csv("out2.csv", float_format="{:.2e}".format) # doctest: +SKIP
>>> df.to_csv("out2.csv", float_format="{{:.2e}}".format) # doctest: +SKIP

@Uvi-12 Uvi-12 requested a review from mroeschke December 3, 2024 18:59
@mroeschke mroeschke added this to the 3.0 milestone Dec 3, 2024
@mroeschke mroeschke merged commit d589839 into pandas-dev:main Dec 3, 2024
51 checks passed
@mroeschke
Copy link
Member

Thanks @Uvi-12

@Uvi-12
Copy link
Contributor Author

Uvi-12 commented Dec 3, 2024

@mroeschke Thank you for the reviews, that helped a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Add examples for float_format in to_csv documentation
2 participants