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: GH11847 Unstack with mixed dtypes coerces everything to object #14053

Closed
wants to merge 1 commit into from

Conversation

kordek
Copy link
Contributor

@kordek kordek commented Aug 20, 2016

Changed the way in which the original data frame is copied (dropped use of .values, since it does not preserve dtypes).

unstacked1 = df.unstack(['index'])
unstacked2 = df.unstack('index')
assert_frame_equal(unstacked1, unstacked2)
assert_numpy_array_equal(df.dtypes.values, unstacked1.dtypes.values)
Copy link
Contributor

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

@kordek kordek force-pushed the #11847 branch 2 times, most recently from f2f08c3 to 18ab88c Compare August 21, 2016 08:04
@codecov-io
Copy link

codecov-io commented Aug 21, 2016

Current coverage is 85.24% (diff: 100%)

Merging #14053 into master will increase coverage by <.01%

@@             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          

Powered by Codecov. Last update 837db72...6a381ce

@@ -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`)
Copy link
Contributor

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

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Dtype Conversions Unexpected or buggy dtype conversions labels Aug 25, 2016
@jreback
Copy link
Contributor

jreback commented Sep 9, 2016

can you rebase / update?

@kordek
Copy link
Contributor Author

kordek commented Nov 16, 2016

@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`)
Copy link
Contributor

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

@kordek kordek force-pushed the #11847 branch 3 times, most recently from 69dd53e to 684e34f Compare November 19, 2016 14:44
@kordek
Copy link
Contributor Author

kordek commented Nov 20, 2016

@jreback changed as suggested and passing.

@jreback jreback added this to the 0.19.2 milestone Nov 21, 2016
@jreback
Copy link
Contributor

jreback commented Nov 23, 2016

@kordek can you add a category dtype the tests as well. lgtm otherwise.

@kordek kordek force-pushed the #11847 branch 2 times, most recently from d14873d to fe559b3 Compare November 27, 2016 09:56
Changed the way in which the original data frame is copied (dropped use of .values, since it does not preserve dtypes).
@kordek
Copy link
Contributor Author

kordek commented Nov 27, 2016

@jreback I've changed the tests as requested (if I understood correctly).

@jreback jreback closed this in d531718 Dec 10, 2016
@jreback
Copy link
Contributor

jreback commented Dec 10, 2016

thanks @kordek

jorisvandenbossche pushed a commit that referenced this pull request Dec 15, 2016
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 <pawel.kordek@gmail.com>

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)
ischurov pushed a commit to ischurov/pandas that referenced this pull request Dec 19, 2016
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 <pawel.kordek@gmail.com>

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstack with mixed dtypes coerces everything to object
4 participants