(any_string_dtype)
| 594 | |
| 595 | |
| 596 | def test_extractall_stringindex(any_string_dtype): |
| 597 | s = Series(["a1a2", "b1", "c1"], name="xxx", dtype=any_string_dtype) |
| 598 | result = s.str.extractall(r"[ab](?P<digit>\d)") |
| 599 | expected = DataFrame( |
| 600 | {"digit": ["1", "2", "1"]}, |
| 601 | index=MultiIndex.from_tuples([(0, 0), (0, 1), (1, 0)], names=[None, "match"]), |
| 602 | dtype=any_string_dtype, |
| 603 | ) |
| 604 | tm.assert_frame_equal(result, expected) |
| 605 | |
| 606 | # index should return the same result as the default index without name thus |
| 607 | # index.name doesn't affect to the result |
| 608 | if any_string_dtype == "object": |
| 609 | for idx in [ |
| 610 | Index(["a1a2", "b1", "c1"], dtype=object), |
| 611 | Index(["a1a2", "b1", "c1"], name="xxx", dtype=object), |
| 612 | ]: |
| 613 | result = idx.str.extractall(r"[ab](?P<digit>\d)") |
| 614 | tm.assert_frame_equal(result, expected) |
| 615 | |
| 616 | s = Series( |
| 617 | ["a1a2", "b1", "c1"], |
| 618 | name="s_name", |
| 619 | index=Index(["XX", "yy", "zz"], name="idx_name"), |
| 620 | dtype=any_string_dtype, |
| 621 | ) |
| 622 | result = s.str.extractall(r"[ab](?P<digit>\d)") |
| 623 | expected = DataFrame( |
| 624 | {"digit": ["1", "2", "1"]}, |
| 625 | index=MultiIndex.from_tuples( |
| 626 | [("XX", 0), ("XX", 1), ("yy", 0)], names=["idx_name", "match"] |
| 627 | ), |
| 628 | dtype=any_string_dtype, |
| 629 | ) |
| 630 | tm.assert_frame_equal(result, expected) |
| 631 | |
| 632 | |
| 633 | def test_extractall_no_capture_groups_raises(any_string_dtype): |
nothing calls this directly
no test coverage detected