Skip to content

Commit 64e0c56

Browse files
committed
updated v3.0.0.rst and fixed tm.assert_produces_warning
1 parent 4840bb6 commit 64e0c56

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Other enhancements
8484
- Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`)
8585
- Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`)
8686
- Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`)
87+
- :meth:`DataFrame.to_csv` and :meth:`Series.to_csv` now support Python's new-style format strings (e.g., ``"{:.6f}"``) for the ``float_format`` parameter, in addition to old-style ``%`` format strings and callables. This allows for more flexible and modern formatting of floating point numbers when exporting to CSV. (:issue:`49580`, :issue:`61650`)
8788

8889
.. ---------------------------------------------------------------------------
8990
.. _whatsnew_300.notable_bug_fixes:

pandas/tests/io/formats/test_to_csv.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import io
22
import os
33
import sys
4-
import warnings
54
from zipfile import ZipFile
65

76
from _csv import Error
@@ -781,8 +780,7 @@ def test_new_style_with_mixed_types():
781780

782781
def test_new_style_with_mixed_types_in_column():
783782
df = DataFrame({"A": [1.23, "text", 4.56]})
784-
with warnings.catch_warnings(record=True):
785-
warnings.simplefilter("always")
783+
with tm.assert_produces_warning(UserWarning):
786784
result = df.to_csv(float_format="{:.2f}", lineterminator="\n")
787785

788786
expected = ",A\n0,1.23\n1,text\n2,4.56\n"

0 commit comments

Comments
 (0)