Skip to content

Commit b7355ed

Browse files
committed
fix: update DataFrame.from_records index parameter to accept Hashable values
- Change index parameter type from SequenceNotStr[str] to SequenceNotStr[Hashable] - Apply black formatting to test files - Resolves CI type checking issues per Dr-Irv feedback This allows index parameter to accept integers and other hashable values, not just strings, matching pandas runtime behavior.
1 parent 3204558 commit b7355ed

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
552552
| Mapping[str, Any]
553553
| Mapping[str, SequenceNotStr[Any]]
554554
),
555-
index: str | SequenceNotStr[str] | None = None,
555+
index: str | SequenceNotStr[Hashable] | None = None,
556556
columns: ListLike | None = None,
557557
exclude: ListLike | None = None,
558558
coerce_float: bool = False,

tests/test_frame.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4735,10 +4735,12 @@ def test_from_records() -> None:
47354735
pd.DataFrame,
47364736
)
47374737

4738-
# test with single dictionary
4738+
# test with single dictionary
47394739
data_single_dict = {"id": 1, "name": "a"}
47404740
check(
4741-
assert_type(pd.DataFrame.from_records(data_single_dict, index=["0"]), pd.DataFrame),
4741+
assert_type(
4742+
pd.DataFrame.from_records(data_single_dict, index=["0"]), pd.DataFrame
4743+
),
47424744
pd.DataFrame,
47434745
)
47444746

0 commit comments

Comments
 (0)