如果我正确理解了您想要的内容,您可以使用numpy.hstack()
它来合并这两者numpy.ndarray
:
import numpy as np
import datetime
dates2008 = [datetime.datetime(2008, 12, i) for i in range(29,32)]
dates2009 = [datetime.datetime(2009, 1, i) for i in range(1,3)]
a = np.array(dates2008)
b= np.array(dates2009)
merged = np.hstack((a,b))
## output ##
print "a = {0}".format(a)
print "b = {0}".format(b)
print "merged = {0}".format(merged)
这将输出:
a = [datetime.datetime(2008, 12, 29, 0, 0)
datetime.datetime(2008, 12, 30, 0, 0)
datetime.datetime(2008, 12, 31, 0, 0)]
b = [datetime.datetime(2009, 1, 1, 0, 0) datetime.datetime(2009, 1, 2, 0, 0)]
merged = [datetime.datetime(2008, 12, 29, 0, 0)
datetime.datetime(2008, 12, 30, 0, 0)
datetime.datetime(2008, 12, 31, 0, 0) datetime.datetime(2009, 1, 1, 0, 0)
datetime.datetime(2009, 1, 2, 0, 0)]