Skip to content

Scalars don't propagate in DataFrame constructor #1329

@wesm

Description

@wesm

This only works if an index is specified; fails in the index inference process

In [1]: DataFrame({'a' : randn(10), 'b' : 6})
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/wesm/code/pandas/<ipython-input-1-16dbfdf3cea7> in <module>()
----> 1 DataFrame({'a' : randn(10), 'b' : 6})

/home/wesm/code/pandas/pandas/core/frame.pyc in __init__(self, data, index, columns, dtype, copy)
    367             mgr = self._init_mgr(data, index, columns, dtype=dtype, copy=copy)
    368         elif isinstance(data, dict):
--> 369             mgr = self._init_dict(data, index, columns, dtype=dtype)
    370         elif isinstance(data, ma.MaskedArray):
    371             mask = ma.getmaskarray(data)

/home/wesm/code/pandas/pandas/core/frame.pyc in _init_dict(self, data, index, columns, dtype)
    446         # figure out the index, if necessary
    447         if index is None:
--> 448             index = extract_index(data)
    449         else:
    450             index = _ensure_index(index)

/home/wesm/code/pandas/pandas/core/frame.pyc in extract_index(data)
   4540             else:
   4541                 have_raw_arrays = True
-> 4542                 raw_lengths.append(len(v))
   4543 
   4544         if have_series or have_dicts:

TypeError: object of type 'int' has no len()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions