Skip to content

Bug in 'chop.threshold' option #6839

Closed
@jseabold

Description

@jseabold
Contributor

xref #6842

Columns where every value is below the threshold disappear. From ML.

In [78]: df.as_matrix()
Out[78]:
array([[  1.00000000e+01,   7.59062963e-10],
    [  2.00000000e+01,  -1.47734680e-11],
    [  3.00000000e+01,   2.18850713e-09],
    [  4.00000000e+01,  -1.86628720e-11]])

In [79]: np.set_printoptions(suppress=True)

In [80]: df.as_matrix()
Out[80]:
array([[ 10.,   0.],
    [ 20.,  -0.],
    [ 30.,   0.],
    [ 40.,  -0.]])


From the docstring, it appears that the 'chop_threshold' option can be
used to do the same thing (and with a threshold as a parameter), but
in this case, it does something weird (perhaps a bug?):

In [81]: pd.set_option('chop_threshold', 1e-8)

In [82]: df
Out[82]:
    0  1
0  10
1  20
2  30
3  40

Activity

added this to the 0.15.0 milestone on May 16, 2014
modified the milestones: 0.16.0, Next Major Release on Mar 3, 2015
dsm054

dsm054 commented on Jun 25, 2017

@dsm054
Contributor

In 0.20.2, this seems to work the way you'd expect:

In [10]: pd.set_option("chop_threshold", 1e-8)

In [11]: df
Out[11]: 
      0             1
0  10.0  0.000000e+00
1  20.0  0.000000e+00
2  30.0  0.000000e+00
3  40.0  0.000000e+00

In [12]: pd.set_option("chop_threshold", 1e-10)

In [13]: df
Out[13]: 
      0             1
0  10.0  7.590630e-10
1  20.0  0.000000e+00
2  30.0  2.188507e-09
3  40.0  0.000000e+00
jreback

jreback commented on Jun 28, 2017

@jreback
Contributor

@dsm054 can you provide a confirming test PR.

7 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugOutput-Formatting__repr__ of pandas objects, to_stringTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @jseabold@jreback@dsm054@TomAugspurger@hayd

      Issue actions

        Bug in 'chop.threshold' option · Issue #6839 · pandas-dev/pandas