Skip to content

Commit 8ac84fa

Browse files
authored
TST: string representation of IntervalIndex (pandas-dev#38242)
1 parent d419ab4 commit 8ac84fa

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

pandas/tests/indexes/interval/test_formats.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import numpy as np
22
import pytest
33

4-
from pandas import DataFrame, IntervalIndex, Series, Timedelta, Timestamp
4+
from pandas import (
5+
DataFrame,
6+
Float64Index,
7+
Interval,
8+
IntervalIndex,
9+
Series,
10+
Timedelta,
11+
Timestamp,
12+
)
513
import pandas._testing as tm
614

715

@@ -37,6 +45,25 @@ def test_repr_missing(self, constructor, expected):
3745
result = repr(obj)
3846
assert result == expected
3947

48+
def test_repr_floats(self):
49+
# GH 32553
50+
51+
markers = Series(
52+
["foo", "bar"],
53+
index=IntervalIndex(
54+
[
55+
Interval(left, right)
56+
for left, right in zip(
57+
Float64Index([329.973, 345.137], dtype="float64"),
58+
Float64Index([345.137, 360.191], dtype="float64"),
59+
)
60+
]
61+
),
62+
)
63+
result = str(markers)
64+
expected = "(329.973, 345.137] foo\n(345.137, 360.191] bar\ndtype: object"
65+
assert result == expected
66+
4067
@pytest.mark.parametrize(
4168
"tuples, closed, expected_data",
4269
[

0 commit comments

Comments
 (0)