いくつかの時系列を共通のDataFrameにマージするのに問題があります。私が使用しているサンプルコード:
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
これにより、serie_5(2番目の連結)のエラーが発生します。
Traceback (most recent call last):
File "C:\Users\User\Workspaces\Python\Source\TestingPandas.py", line 29, in <module>
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'
結果を次のようにしたいと思います(2列目にランダムな値があります)。
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
なにが問題ですか?私が言ったように、おそらく基本的ですが、私はそれを理解することができず、私は初心者です...