(熊猫 0.10.1)
简单的例子在这里。
import pandas
import pandas.util.testing as PUT
ts1 = PUT.makeTimeSeries(3) ## not zero
ts2 = PUT.makeTimeSeries(3) * 0.0 ## zeros
ts1.name = 'ts'
ts2.name = 'ts'
df = pandas.concat([ts1,ts2], axis = 1)
print df
ts ts
2000-01-03 -0 -0
2000-01-04 0 0
2000-01-05 0 0
或者反过来,
df = pandas.concat([ts2,ts1], axis = 1)
ts ts
2000-01-03 0.615385 0.615385
2000-01-04 -0.881817 -0.881817
2000-01-05 2.354081 2.354081
垂直连接很好
df = pandas.concat([ts2,ts1], axis = 0)
2000-01-03 -0.000000
2000-01-04 0.000000
2000-01-05 0.000000
2000-01-03 0.615385
2000-01-04 -0.881817
2000-01-05 2.354081
Name: ts
原来的 ts1 和 ts2 虽然没有被覆盖
print ts1
2000-01-03 0.615385
2000-01-04 -0.881817
2000-01-05 2.354081
Freq: B, Name: ts
print ts2
2000-01-03 -0
2000-01-04 0
2000-01-05 0
Freq: B, Name: ts
顺便说一句,如果你连接两个具有相同列名的 DF,结果是正确的