pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.6k stars 17.9k forks source link

DataFrame construction breaks python on numpy empty_like #14082

Closed asishm closed 8 years ago

asishm commented 8 years ago

Code Sample, a copy-pastable example if possible

http://stackoverflow.com/questions/39129419/why-does-dataframe-construction-break-python-on-numpy-empty-like

import numpy as np
import pandas as pd

a = np.array([None, None], dtype=object)
print(a)      # [None None]

dfa = pd.DataFrame(a)
print(dfa)

#      0
#0  None
#1  None

b = np.empty_like(a)
print(b)

#[None None]

(a == b).all()

#True

dfb = pd.DataFrame(b)  # Fine so far
print(dfb.values)

#[[None]
 #[None]]

print(dfb)  #Crash

Expected Output

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 18.2
Cython: None
numpy: 1.11.1
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.5.0
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
jreback commented 8 years ago

duplicate of #13717 and fixed by #13764 in master / not-yet-released 0.19.0