Note that there are some explanatory texts on larger screens.

plurals
  1. POSeveral time series to DataFrame
    primarykey
    data
    text
    <p>I have problem merging several time series to a common DataFrame. The example code I'm using:</p> <pre><code>import pandas import datetime import numpy as np start = datetime.datetime(2001, 1, 1) end = datetime.datetime(2001, 1, 10) dates = pandas.date_range(start, end) serie_1 = pandas.Series(np.random.randn(10), index = dates) start = datetime.datetime(2001, 1, 2) end = datetime.datetime(2001, 1, 11) dates = pandas.date_range(start, end) serie_2 = pandas.Series(np.random.randn(10), index = dates) start = datetime.datetime(2001, 1, 3) end = datetime.datetime(2001, 1, 12) dates = pandas.date_range(start, end) serie_3 = pandas.Series(np.random.randn(10), index = dates) print 'serie_1' print serie_1 print 'serie_2' print serie_2 print 'serie_3' print serie_3 serie_4 = pandas.concat([serie_1,serie_2], join='outer', axis = 1) print 'serie_4' print serie_4 serie_5 = pandas.concat([serie_4, serie_3], join='outer', axis = 1) print 'serie_5' print serie_5 </code></pre> <p>This gives me the error for serie_5 (the second concat): </p> <pre><code>Traceback (most recent call last): File "C:\Users\User\Workspaces\Python\Source\TestingPandas.py", line 29, in &lt;module&gt; serie_5 = pandas.concat([serie_4, serie_3], join='outer', axis = 1) File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 878, in concat verify_integrity=verify_integrity) File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 948, in __init__ self.new_axes = self._get_new_axes() File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 1101, in _get_new_axes new_axes[i] = self._get_comb_axis(i) File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 1125, in _get_comb_axis all_indexes = [x._data.axes[i] for x in self.objs] AttributeError: 'TimeSeries' object has no attribute '_data' </code></pre> <p>I would like the result to look something like this (with random values in column 2):</p> <pre><code> 0 1 2 2001-01-01 -1.224602 NaN NaN 2001-01-02 -1.747710 -2.618369 NaN 2001-01-03 -0.608578 -0.030674 -1.335857 2001-01-04 1.503808 -0.050492 1.086147 2001-01-05 0.593152 0.834805 -1.310452 2001-01-06 -0.156984 0.208565 -0.972561 2001-01-07 0.650264 -0.340086 1.562101 2001-01-08 -0.063765 -0.250005 -0.508458 2001-01-09 -1.092656 -1.589261 -0.481741 2001-01-10 0.640306 0.333527 -0.111668 2001-01-11 NaN -1.159637 0.110722 2001-01-12 NaN NaN -0.409387 </code></pre> <p>What is wrong? As I said, probablybasic but I can not figure it out and I'm a beginner...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload