-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: GH11847 Unstack with mixed dtypes coerces everything to object #14053
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
unstacked1 = df.unstack(['index']) | ||
unstacked2 = df.unstack('index') | ||
assert_frame_equal(unstacked1, unstacked2) | ||
assert_numpy_array_equal(df.dtypes.values, unstacked1.dtypes.values) |
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.
no need to compare vs numpy
frame_equal does this
f2f08c3
to
18ab88c
Compare
Current coverage is 85.24% (diff: 100%)@@ master #14053 diff @@
==========================================
Files 143 143
Lines 50849 50851 +2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43343 43346 +3
+ Misses 7506 7505 -1
Partials 0 0
|
@@ -1079,3 +1079,4 @@ Bug Fixes | |||
- Bug in ``Index`` raises ``KeyError`` displaying incorrect column when column is not in the df and columns contains duplicate values (:issue:`13822`) | |||
- Bug in ``Period`` and ``PeriodIndex`` creating wrong dates when frequency has combined offset aliases (:issue:`13874`) | |||
- Bug in ``.to_string()`` when called with an integer ``line_width`` and ``index=False`` raises an UnboundLocalError exception because ``idx`` referenced before assignment. | |||
- Bug in ``unstack()`` causes specific series dtype to be changed to ``object`` (:issue:`11847`) |
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.
not clear to a reader what this means. use more description from the issue
can you rebase / update? |
0b7548c
to
47938ad
Compare
@jreback is it ok now? |
@@ -80,3 +80,5 @@ Performance Improvements | |||
|
|||
Bug Fixes | |||
~~~~~~~~~ | |||
|
|||
- Bug in ``unstack()`` If called with list of column(s) as argument, regardless of dtypes all columns get coerced to ``object`` (:issue:`11847`) |
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.
ok to move to 0.19.2
small changes
Bug in unstack()
if called with a list of column(s) as an argument, regardless of the dtypes of all columns get coerced to object
dtype
69dd53e
to
684e34f
Compare
@jreback changed as suggested and passing. |
@kordek can you add a category dtype the tests as well. lgtm otherwise. |
d14873d
to
fe559b3
Compare
Changed the way in which the original data frame is copied (dropped use of .values, since it does not preserve dtypes).
@jreback I've changed the tests as requested (if I understood correctly). |
thanks @kordek |
closes #11847 Changed the way in which the original data frame is copied (dropped use of .values, since it does not preserve dtypes). Author: Pawel Kordek <[email protected]> Closes #14053 from kordek/#11847 and squashes the following commits: 6a381ce [Pawel Kordek] BUG: GH11847 Unstack with mixed dtypes coerces everything to object (cherry picked from commit d531718)
closes pandas-dev#11847 Changed the way in which the original data frame is copied (dropped use of .values, since it does not preserve dtypes). Author: Pawel Kordek <[email protected]> Closes pandas-dev#14053 from kordek/pandas-dev#11847 and squashes the following commits: 6a381ce [Pawel Kordek] BUG: GH11847 Unstack with mixed dtypes coerces everything to object
git diff upstream/master | flake8 --diff
Changed the way in which the original data frame is copied (dropped use of .values, since it does not preserve dtypes).