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: Segmentation fault using tuple as iterator for DataFrame constructor #25691

Closed
simonjayhawkins opened this issue Mar 12, 2019 · 0 comments · Fixed by #25731
Closed

BUG: Segmentation fault using tuple as iterator for DataFrame constructor #25691

simonjayhawkins opened this issue Mar 12, 2019 · 0 comments · Fixed by #25731
Labels
Bug DataFrame DataFrame data structure
Milestone

Comments

@simonjayhawkins
Copy link
Member

Code Sample, a copy-pastable example if possible

Python 3.7.2 (default, Feb 21 2019, 17:35:59) [MSC v.1915 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pandas as pd

In [2]: pd.DataFrame(())
Out[2]: 
Empty DataFrame
Columns: []
Index: []

In [3]: pd.DataFrame((()))
Out[3]: 
Empty DataFrame
Columns: []
Index: []

In [4]: pd.DataFrame(((),()))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-8f97dbc592ec> in <module>
----> 1 pd.DataFrame(((),()))

~\OneDrive\code\pandas-simonjayhawkins\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy)
    433                     if is_named_tuple(data[0]) and columns is None:
    434                         columns = data[0]._fields
--> 435                     arrays, columns = to_arrays(data, columns, dtype=dtype)
    436                     columns = ensure_index(columns)
    437

~\OneDrive\code\pandas-simonjayhawkins\pandas\core\internals\construction.py in to_arrays(data, columns, coerce_float, dtype)
    396     if isinstance(data[0], (list, tuple)):
    397         return _list_to_arrays(data, columns, coerce_float=coerce_float,
--> 398                                dtype=dtype)
    399     elif isinstance(data[0], compat.Mapping):
    400         return _list_of_dict_to_arrays(data, columns,

~\OneDrive\code\pandas-simonjayhawkins\pandas\core\internals\construction.py in _list_to_arrays(data, columns, coerce_float, dtype)
    423 def _list_to_arrays(data, columns, coerce_float=False, dtype=None):
    424     if len(data) > 0 and isinstance(data[0], tuple):
--> 425         content = list(lib.to_object_array_tuples(data).T)
    426     else:
    427         # list of lists

TypeError: Argument 'rows' has incorrect type (expected list, got tuple)

In [6]: pd.DataFrame(([],[]))
Segmentation fault

on 23.4

Python 3.7.2 (default, Feb 21 2019, 17:35:59) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.__version__
'0.23.4'
>>> pd.DataFrame(((),()))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\Anaconda3\envs\pandas-dev\lib\site-packages\pandas\core\frame.py", line 422, in __init__
    raise ValueError('DataFrame constructor not properly called!')
ValueError: DataFrame constructor not properly called!
>>> pd.DataFrame(([],[]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\Anaconda3\envs\pandas-dev\lib\site-packages\pandas\core\frame.py", line 422, in __init__
    raise ValueError('DataFrame constructor not properly called!')
ValueError: DataFrame constructor not properly called!

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: c285290
python: 3.7.2.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: None.None

pandas: 0.25.0.dev0+240.gc28529051.dirty
pytest: 4.3.0
pip: 19.0.3
setuptools: 40.6.3
Cython: 0.29.5
numpy: 1.16.2
scipy: 1.2.1
pyarrow: 0.11.1
xarray: 0.11.3
IPython: 7.3.0
sphinx: 1.8.4
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 3.0.2
openpyxl: 2.6.0
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.5
lxml.etree: 4.3.1
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.2.18
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: 0.2.0
fastparquet: 0.2.1
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug DataFrame DataFrame data structure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants