-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Ensure .astype doesn't use PandasArray #24866
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
On 0.24.0rc1, it's possible to end up with a PandasArray in internals. ```python In [8]: ser = pd.Series([1, 2]) In [9]: ser.astype(ser.array.dtype)._data.blocks[0] Out[9]: ExtensionBlock: 2 dtype: int64 ```
Subclasses overriding Block._astype get the sanitized version as well,
which is arguably what we want.
…On Mon, Jan 21, 2019 at 3:04 PM Jeff Reback ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pandas/core/internals/blocks.py
<#24866 (comment)>:
> @@ -530,6 +530,10 @@ def f(m, v, i):
return self.split_and_operate(None, f, False)
def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs):
+ dtype = pandas_dtype(dtype)
i don’t want to put this clause where the existing is?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#24866 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIqfSCJx3q0PFLshrku91aZL-rkdwks5vFit2gaJpZM4aLZlp>
.
|
Codecov Report
@@ Coverage Diff @@
## master #24866 +/- ##
===========================================
- Coverage 92.39% 42.88% -49.51%
===========================================
Files 166 166
Lines 52412 52414 +2
===========================================
- Hits 48424 22479 -25945
- Misses 3988 29935 +25947
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24866 +/- ##
==========================================
- Coverage 91.98% 91.97% -0.02%
==========================================
Files 175 175
Lines 52372 52369 -3
==========================================
- Hits 48172 48164 -8
- Misses 4200 4205 +5
Continue to review full report at Codecov.
|
# astype processing | ||
if is_dtype_equal(self.dtype, dtype): | ||
if copy: | ||
return self.copy() | ||
return self | ||
|
||
klass = None |
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.
I believe that this is unnecessary now... The .astype
should get us an array of the correct type, and from there we'll get the correct block in make_block
.
All green. I'm a bit concerned that this is the wrong place to fix the issue. We could alternatively put this check in |
Trying to move it to |
needs a retest, can you merge master |
merged master; lets see |
thanks @TomAugspurger |
On 0.24.0rc1, it's possible to end up with a PandasArray in internals.