Skip to content

Commit 5d1c154

Browse files
committed
one new test just for the mixed string in indices_dict (pandas\confets.py)
1 parent 416a6ae commit 5d1c154

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
import pandas as pd
3+
4+
def test_mixed_int_string_index():
5+
idx = pd.Index([0, "a", 1, "b", 2, "c"])
6+
7+
# Check if the index is of type Index
8+
assert len(idx) == 6
9+
assert idx[1] == "a"
10+
assert idx[-1] == "c"
11+
12+
# Check if the index is sorted (it should not be)
13+
with pytest.raises(TypeError):
14+
idx.sort_values()
15+
16+
# Check if the index is unique
17+
assert idx.is_unique
18+
19+
# Check if the index contains a specific value
20+
assert idx.get_loc("a") == 1
21+
with pytest.raises(KeyError):
22+
idx.get_loc("z")

0 commit comments

Comments
 (0)