BUG: fix col iteration in DataFrame.round, #11611 #11618

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

skycaptain commented Nov 16, 2015

Fixes #11611. The iterator now uses DataFrame.iteritems instead of direct indexing.

@MaximilianR MaximilianR commented on the diff Nov 16, 2015

pandas/core/frame.py
try:
- yield np.round(df[col], decimals[col])
+ yield np.round(vals, decimals[col])
@MaximilianR

MaximilianR Nov 16, 2015

Contributor

Is the decimals lookup going to have the same problem if it's not unique here?

@skycaptain

skycaptain Nov 16, 2015

Contributor

The value of decimals is either of type dict or pandas.Series. Whereas the former can not have duplicate entries, a pandas.Series might have and direct indexing will return all values with the same index. So, this case is still not handled.

@jreback

jreback Nov 18, 2015

Contributor

I think let's raise if decimals is not unique (it should be a dict/Series).

@skycaptain

skycaptain Nov 18, 2015

Contributor

Had the same thought this morning.

Contributor

jreback commented Nov 16, 2015

need some tests

Contributor

jreback commented Nov 18, 2015

pls add the test example as well (you can just smoke tests it I think; e.g. assert it runs).

add a tests for passing a non-unique decimal.

put this in the bug-fix section for a whatsnew entry.

Contributor

skycaptain commented Nov 18, 2015

Agreed.

jreback added this to the 0.17.1 milestone Nov 20, 2015

@jreback jreback added a commit that referenced this pull request Nov 20, 2015

@skycaptain @jreback skycaptain + jreback BUG: fix col iteration in DataFrame.round, #11611
BUG: decimals must be unique indexed, #11618

BUG: Added test, added whatsnew entry, #11618

TST: move round testing to test_format.py
80a2d53
Contributor

jreback commented Nov 20, 2015

merged via 80a2d53

thanks!

jreback closed this Nov 20, 2015

skycaptain deleted the unknown repository branch Nov 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment