Skip to content
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

BUG GH16983 fix df.where with extension dtypes #24169

Closed
wants to merge 1 commit into from

Conversation

JustinZhengBC
Copy link
Contributor

The referenced issue showcases two bugs. I was not able to replicate the first one, but I tracked down the cause of the ndim ValueError in the second example. An ExtensionBlock passed to df.where used to be unpacked here into a 1D array while normal blocks are unpacked earlier here into a 2D nx1 array.

@pep8speaks
Copy link

Hello @JustinZhengBC! Thanks for submitting the PR.

@codecov
Copy link

codecov bot commented Dec 9, 2018

Codecov Report

Merging #24169 into master will increase coverage by 49.18%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #24169       +/-   ##
===========================================
+ Coverage   43.02%   92.21%   +49.18%     
===========================================
  Files         162      162               
  Lines       51700    51702        +2     
===========================================
+ Hits        22245    47675    +25430     
+ Misses      29455     4027    -25428
Flag Coverage Δ
#multiple 90.61% <100%> (?)
#single 43.02% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals/blocks.py 93.66% <100%> (+40.79%) ⬆️
pandas/core/computation/pytables.py 92.37% <0%> (+0.3%) ⬆️
pandas/io/pytables.py 92.3% <0%> (+0.92%) ⬆️
pandas/util/_test_decorators.py 93.24% <0%> (+4.05%) ⬆️
pandas/compat/__init__.py 58.3% <0%> (+8.1%) ⬆️
pandas/core/config_init.py 99.24% <0%> (+9.84%) ⬆️
pandas/core/reshape/util.py 100% <0%> (+11.53%) ⬆️
pandas/compat/numpy/__init__.py 92.85% <0%> (+14.28%) ⬆️
pandas/core/computation/common.py 85.71% <0%> (+14.28%) ⬆️
pandas/core/api.py 100% <0%> (+14.81%) ⬆️
... and 120 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update defa8a8...d623ea0. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Dec 9, 2018

Codecov Report

Merging #24169 into master will increase coverage by 49.18%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #24169       +/-   ##
===========================================
+ Coverage   43.02%   92.21%   +49.18%     
===========================================
  Files         162      162               
  Lines       51700    51702        +2     
===========================================
+ Hits        22245    47675    +25430     
+ Misses      29455     4027    -25428
Flag Coverage Δ
#multiple 90.61% <100%> (?)
#single 43.02% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals/blocks.py 93.66% <100%> (+40.79%) ⬆️
pandas/core/computation/pytables.py 92.37% <0%> (+0.3%) ⬆️
pandas/io/pytables.py 92.3% <0%> (+0.92%) ⬆️
pandas/util/_test_decorators.py 93.24% <0%> (+4.05%) ⬆️
pandas/compat/__init__.py 58.3% <0%> (+8.1%) ⬆️
pandas/core/config_init.py 99.24% <0%> (+9.84%) ⬆️
pandas/core/reshape/util.py 100% <0%> (+11.53%) ⬆️
pandas/compat/numpy/__init__.py 92.85% <0%> (+14.28%) ⬆️
pandas/core/computation/common.py 85.71% <0%> (+14.28%) ⬆️
pandas/core/api.py 100% <0%> (+14.81%) ⬆️
... and 120 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update defa8a8...d623ea0. Read the comment docs.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Dec 9, 2018

#24114 is fixing this.

@@ -1341,6 +1341,8 @@ def func(cond, values, other):
return values

values, other = self._try_coerce_args(values, other)
if isinstance(values, ExtensionArray):
values = values.get_values().reshape(-1, 1) # GH 16983
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI, we want to avoid get_values since that converts the ExtensionArray to an ndarray.

@jreback jreback closed this Dec 9, 2018
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.

BUG: DataFrame.astype with category dtype
4 participants