Skip to content

Commit 544e8a0

Browse files
author
sah0725
committed
docs: add missing StringIO import and fix remaining file I/O
1 parent b8c48e6 commit 544e8a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

doc/source/user_guide/io.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,10 +1827,12 @@ Best practices
18271827

18281828
.. ipython:: python
18291829
1830+
from io import StringIO
1831+
18301832
def test_roundtrip_precision(df, float_format):
18311833
"""Test if a float_format preserves data during CSV roundtrip."""
1832-
df.to_csv('test.csv', index=False, float_format=float_format)
1833-
df_read = pd.read_csv('test.csv')
1834+
csv_string = df.to_csv(index=False, float_format=float_format)
1835+
df_read = pd.read_csv(StringIO(csv_string))
18341836
return df.equals(df_read)
18351837
18361838
# Test data

0 commit comments

Comments
 (0)