-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: SparseArray.astype(np.int64) #49704
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
Conversation
dtype = cast(ExtensionDtype, dtype) | ||
cls = dtype.construct_array_type() | ||
return cls._from_sequence(self, dtype=dtype, copy=copy) | ||
values = np.asarray(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this robust if the original type was pd.SparseDtype(pd.Int64Dtype)
with an NA
and astype(pd.Int32Dtype)
was called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh looks like there an existing bug here too (missing import)
In [1]: arr = pd.array([1, pd.NA], dtype=pd.SparseDtype(pd.Int64Dtype()))
In [2]: arr
Out[2]:
[1, <NA>]
Fill: <NA>
IntIndex
Indices: array([0], dtype=int32)
In [3]: arr.dtype
Out[3]: Sparse[Int64, <NA>]
In [4]: arr.astype(pd.Int16Dtype())
NameError: name 'ExtensionDtype' is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah, though i think that was introduced by a pylint PR really recently. updatenope it was introduced by me 15 days ago
also IIUC pd.SparseDtype(EADtype) shouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you raise a NotImplementedError
for the EADtypes here for now then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id rather do that as separately to Do It Right along with a couple other bugs mentioned in #49631
Thanks @jbrockmendel |
* BUG: SparseArray.astype(np.int64) * whatsnew
* BUG: SparseArray.astype(np.int64) * whatsnew
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.