Skip to content

Commit 423eea1

Browse files
committed
Remove extra space and add context manager to test
1 parent d97bcd7 commit 423eea1

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

pandas/core/frame.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,12 +2497,12 @@ def memory_usage(self, index=True, deep=False):
24972497
... for t in dtypes])
24982498
>>> df = pd.DataFrame(data)
24992499
>>> df.head()
2500-
int64 float64 complex128 object bool
2501-
0 1 1.0 1.0+0.0j 1 True
2502-
1 1 1.0 1.0+0.0j 1 True
2503-
2 1 1.0 1.0+0.0j 1 True
2504-
3 1 1.0 1.0+0.0j 1 True
2505-
4 1 1.0 1.0+0.0j 1 True
2500+
int64 float64 complex128 object bool
2501+
0 1 1.0 1.0+0.0j 1 True
2502+
1 1 1.0 1.0+0.0j 1 True
2503+
2 1 1.0 1.0+0.0j 1 True
2504+
3 1 1.0 1.0+0.0j 1 True
2505+
4 1 1.0 1.0+0.0j 1 True
25062506
25072507
>>> df.memory_usage()
25082508
Index 80

pandas/tests/io/formats/test_format.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,16 +1371,16 @@ def test_to_string_float_index(self):
13711371
assert result == expected
13721372

13731373
def test_to_string_complex_float_formatting(self):
1374-
fmt.set_option('display.precision', 5)
1375-
df = DataFrame({'x': [
1376-
(0.4467846931321966 + 0.0715185102060818j),
1377-
(0.2739442392974528 + 0.23515228785438969j),
1378-
(0.26974928742135185 + 0.3250604054898979j)]})
1379-
result = df.to_string()
1380-
expected = (' x\n0 0.44678+0.07152j\n'
1381-
'1 0.27394+0.23515j\n'
1382-
'2 0.26975+0.32506j')
1383-
assert result == expected
1374+
with pd.option_context('display.precision', 5):
1375+
df = DataFrame({'x': [
1376+
(0.4467846931321966 + 0.0715185102060818j),
1377+
(0.2739442392974528 + 0.23515228785438969j),
1378+
(0.26974928742135185 + 0.3250604054898979j)]})
1379+
result = df.to_string()
1380+
expected = (' x\n0 0.44678+0.07152j\n'
1381+
'1 0.27394+0.23515j\n'
1382+
'2 0.26975+0.32506j')
1383+
assert result == expected
13841384

13851385
def test_to_string_ascii_error(self):
13861386
data = [('0 ', ' .gitignore ', ' 5 ',

0 commit comments

Comments
 (0)