You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't create a DataFrame from this array using the DataFrame constructor:
pd.DataFrame(ts_array)
Traceback (most recent call last):
File "/Users/jkelleher/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2885, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-46-ae20c6b6248f>", line 1, in <module>
pd.DataFrame(ts_array)
File "/Users/jkelleher/anaconda/lib/python2.7/site-packages/pandas/core/frame.py", line 255, in __init__
copy=copy)
File "/Users/jkelleher/anaconda/lib/python2.7/site-packages/pandas/core/frame.py", line 432, in _init_ndarray
return create_block_manager_from_blocks([values], [columns, index])
File "/Users/jkelleher/anaconda/lib/python2.7/site-packages/pandas/core/internals.py", line 3986, in create_block_manager_from_blocks
mgr = BlockManager(blocks, axes)
File "/Users/jkelleher/anaconda/lib/python2.7/site-packages/pandas/core/internals.py", line 2591, in __init__
(block.ndim, self.ndim))
AssertionError: Number of Block dimensions (1) must equal number of axes (2)
I can create the DataFrame from the array using from_records:
ts_df=pd.DataFrame.from_records(ts_array)
However, when I attempt to transpose this DataFrame, I wind up with the same AssertionError as before.
AssertionError: Number of Block dimensions (1) must equal number of axes (2)
If I convert the Timestamps to Datetimes, the error persists. I can, however, convert the Timestamps to Datetime64 objects, and this fixes the problem.
Though I found a suitable workaround, I feel like pandas should be able to construct and operate on DataFrames of Timestamps as easily as other other objects.
I suppose its a bug, but you are just going about this the wrong way to have a 2- d numpy array of Timestamps (which is completely inefficient) THEN create a frame.
I have the following array of Timestamps:
I can't create a DataFrame from this array using the DataFrame constructor:
I can create the DataFrame from the array using
from_records
:However, when I attempt to transpose this DataFrame, I wind up with the same
AssertionError
as before.If I convert the Timestamps to Datetimes, the error persists. I can, however, convert the Timestamps to Datetime64 objects, and this fixes the problem.
Though I found a suitable workaround, I feel like pandas should be able to construct and operate on DataFrames of Timestamps as easily as other other objects.
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: