Skip to content

Bug: Bizarre DataFrame printing inconsistency (REPL only) #4531

Closed
@gpcz

Description

@gpcz

Pandas 0.12.0 fails to print a column change in this specific example:

Python 2.7.3 (default, Apr 10 2013, 05:13:16) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import pandas
>>> length = 5
>>> xx = pandas.DataFrame({'a':np.random.randn(length),'b':np.random.randn(length),'c':np.random.randn(length)})
>>> xx['d']=xx['a']
>>> np.may_share_memory(xx['d'],xx['a'])
False
>>> print xx
          a         b         c         d
0  0.370188  0.437854 -0.020475  0.370188
1  1.839874  0.539278  0.954254  1.839874
2  0.183890 -0.924539 -0.943913  0.183890
3 -2.047403  1.213499 -0.742084 -2.047403
4 -1.003271  0.839525  0.154962 -1.003271
>>> xx['d'][1] = 42
>>> print xx
          a         b         c         d
0  0.370188  0.437854 -0.020475  0.370188
1  1.839874  0.539278  0.954254  1.839874
2  0.183890 -0.924539 -0.943913  0.183890
3 -2.047403  1.213499 -0.742084 -2.047403
4 -1.003271  0.839525  0.154962 -1.003271
>>> quit()

Cell D1 should be 42 in the last print statement.

After poking at this a bit, I discovered the following additional required conditions:

  1. You must enter this in the Python REPL (as in typing "python" at the command line and entering them manually). If you put the commands in a file and run the file, it will suddenly do what's expected.
  2. The np.may_share_memory() call must be there. If you omit it, it will suddenly do what's expected.
  3. A friend of mine attempted to reproduce this bug on Pandas 0.11.0, but he couldn't get it to work. Then again, he may have messed up conditions 1 and/or 2 -- he tried it before I realized the previous two conditions.

I am using Pandas '0.12.0' installed from pip on Linux Mint 14. Here is the (relevant) output from print_versions.py:

INSTALLED VERSIONS
------------------
Python: 2.7.3.final.0
OS: Linux 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8

Cython: Not installed
Numpy: 1.6.2
Scipy: 0.10.1
matplotlib: 1.1.1
lxml: 2.3.5

I have no idea where the root cause of this bug is -- it may not necessarily be pandas's fault. I just hope someone else can reproduce it...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions