Skip to content

BUG: 54445 interferes with EAs that support complex128 #54540

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

Closed
Closed
Changes from all commits
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: 12 additions & 5 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,11 +983,18 @@ def fast_xs(self, loc: int) -> SingleBlockManager:
)
result = ensure_wrapped_if_datetimelike(result)

for blk in self.blocks:
# Such assignment may incorrectly coerce NaT to None
# result[blk.mgr_locs] = blk._slice((slice(None), loc))
for i, rl in enumerate(blk.mgr_locs):
result[rl] = blk.iget((i, loc))
try:
for blk in self.blocks:
# Such assignment may incorrectly coerce NaT to None
# result[blk.mgr_locs] = blk._slice((slice(None), loc))
for i, rl in enumerate(blk.mgr_locs):
result[rl] = blk.iget((i, loc))
except TypeError:
if isinstance(dtype, ExtensionDtype) and not immutable_ea:
values = [v[loc] for v in self.arrays]
Copy link
Member

Choose a reason for hiding this comment

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

this will only work in some fairly specific all-EA cases

Copy link
Member

Choose a reason for hiding this comment

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

im skeptical this is the way to go, will discuss in the #54445 to try to get an idea of where the underlying problem is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe the solution is to use a (np.nan+0j) as the na_value, and maybe na_values should be the largest thing an array should be required to hold, not the smallest or simplest?

result = cls._from_sequence(values, dtype=dtype)
else:
raise TypeError

if immutable_ea:
dtype = cast(ExtensionDtype, dtype)
Expand Down