Skip to content

GH1217 Modify items/iterros/itertuples methods to return Iterator #1225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,22 @@ def test_types_itertuples() -> None:
)

for t1 in df.itertuples():
check(assert_type(t1, _PandasNamedTuple), _PandasNamedTuple)
assert_type(t1, _PandasNamedTuple)
assert t1.__class__.__name__ == "Pandas"
assert isinstance(t1.Index, int)
assert isinstance(t1.col1, int)
assert isinstance(t1.col2, int)
for k in [0, 1]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop and the one below should be for k in [0,1,2] since the tuple has 3 components.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes correct I thought it was iterating over the number of elements.

assert isinstance(t1[k], int)

for t1 in df.itertuples(name="FooBar"):
assert_type(t1, _PandasNamedTuple)
assert t1.__class__.__name__ == "FooBar"
assert isinstance(t1.Index, int)
assert isinstance(t1.col1, int)
assert isinstance(t1.col2, int)
for k in [0, 1]:
assert isinstance(t1[k], int)


def test_types_items() -> None:
Expand Down