Skip to content

GH1248/GH1249 DataFrame.assign and MultiIndex.from_product Series/Index #1250

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

loicdiridollou
Copy link
Member

@loicdiridollou loicdiridollou requested a review from Dr-Irv June 13, 2025 22:22
AnyArrayLike | Scalar | Callable[[DataFrame], AnyArrayLike | Scalar] | None
AnyArrayLike
| Scalar
| Callable[[DataFrame], AnyArrayLike | Scalar | list[Scalar] | range]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| Callable[[DataFrame], AnyArrayLike | Scalar | list[Scalar] | range]
| Callable[[DataFrame], AnyArrayLike | Scalar | list[Scalar] | range] |
list[Scalar] | range

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed

Comment on lines 65 to 66
mi = pd.MultiIndex.from_product([["x", "y"], df.columns])
mi = pd.MultiIndex.from_product([["x", "y"], pd.Series([1, 2])])
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add the check(assert_type( pattern here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

df = pd.DataFrame({"a": [1, 2, 3]})
check(
assert_type(
df.assign(b=lambda df: range(len(df)), c=lambda df: [10, 20, 30]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

also want to test df.assign(b=range(len(df)), c=[10,20,30])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame.assign() should allow a list and a range
2 participants