Skip to content

DataFrame.to_records failure with DatetimeIndex #1720

@wesm

Description

@wesm

http://stackoverflow.com/questions/11754334/dataframe-to-records-gives-an-error-when-typeindex-is-datetimeindex

In [20]: df = read_clipboard(sep='\s+', parse_dates=True)

In [21]: df
Out[21]: 
                   a         b         c
2012-08-01  2.355928 -2.465061  0.240094
2012-08-02 -0.952323  0.746623 -0.384021
2012-08-03  1.460156  0.292560 -0.494793
2012-08-04 -0.989584 -1.630384  1.373587
2012-08-05  0.014760 -0.789603 -0.622780

In [22]: df.to_records()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-6d3142e97d2d> in <module>()
----> 1 df.to_records()

/Users/wesm/code/pandas/pandas/core/frame.pyc in to_records(self, index)
    889             names = list(map(str, self.columns))
    890 
--> 891         return np.rec.fromarrays(arrays, names=names)
    892 
    893     @classmethod

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/numpy/core/records.pyc in fromarrays(arrayList, dtype, shape, formats, names, titles, aligned, byteorder)
    546     # Determine shape from data-type.
    547     if len(descr) != len(arrayList):
--> 548         raise ValueError, "mismatch between the number of fields "\
    549               "and the number of arrays"
    550 

ValueError: mismatch between the number of fields and the number of arrays

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