Skip to content

Commit d589839

Browse files
authored
DOC: Examples added for float_format in to_csv documentation (#60457)
* Checking for the first link added * DOC: Added missing links to optional dependencies in getting_started/install.html * DOC: Examples added for float_format in to_csv documentation * Updated the float_format based on suggested change * Changes made according to the review
1 parent 844b319 commit d589839

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/core/generic.py

+8
Original file line numberDiff line numberDiff line change
@@ -3878,6 +3878,14 @@ def to_csv(
38783878
>>> import os # doctest: +SKIP
38793879
>>> os.makedirs("folder/subfolder", exist_ok=True) # doctest: +SKIP
38803880
>>> df.to_csv("folder/subfolder/out.csv") # doctest: +SKIP
3881+
3882+
Format floats to two decimal places:
3883+
3884+
>>> df.to_csv("out1.csv", float_format="%.2f") # doctest: +SKIP
3885+
3886+
Format floats using scientific notation:
3887+
3888+
>>> df.to_csv("out2.csv", float_format="{{:.2e}}".format) # doctest: +SKIP
38813889
"""
38823890
df = self if isinstance(self, ABCDataFrame) else self.to_frame()
38833891

0 commit comments

Comments
 (0)