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

Scalars don't propagate in DataFrame constructor #1329

wesm opened this issue May 28, 2012 · 0 comments


Copy link

commented May 28, 2012

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))
   4544         if have_series or have_dicts:

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

@wesm wesm closed this in 3c1cc35 May 28, 2012

yarikoptic added a commit to neurodebian/pandas that referenced this issue Jun 21, 2012
Merge tag 'v0.8.0b1' into debian-0.8
Version 0.8.0 beta 1

* tag 'v0.8.0b1': (703 commits)
  RLS: 0.8.0 beta 1
  RLS: 0.8.0beta
  RLS: release notes
  ENH: add option to use Series.values to interpolate, close pandas-dev#1206
  TST: testing to close pandas-dev#1331
  DOC: groupby drop duplicate index pandas-dev#1312
  ENH: tz_convert for DataFrame pandas-dev#1330
  ENH: add NA handling to scatter_matrix, close pandas-dev#1297
  BUG: display localtime in DatetimeIndex.__repr__, close pandas-dev#1336
  DOC: draft of timeseries section of docs. Added Period related documentation and examples
  DOC: timezone handling and started on Period
  DOC: rough draft of DatetimeIndex, date_range, shifting/resampling etc
  DOC: more ts docs. Need to do resampling then PeriodIndex
  DOC: starting deeper revamp of ts docs for 0.8
  BUG: raise exception for unintellible frequency strings, close pandas-dev#1328
  ENH: construct PeriodIndex from arrays of fields, allow negative ordinals. close pandas-dev#1333 and pandas-dev#1264
  BUG: tsplot fix with business freq pandas-dev#1332
  BUG: DatetimeIndex partial slicing bug, tsplot kludge around pandas-dev#1332
  BUG: alias W to W-SUN, add test for buglet close pandas-dev#1327
  ENH: mix arrays and scalars in DataFrame constructor, close pandas-dev#1329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.