我正在尝试探索 Pandas 库,并通过一个我经常遇到的例子停下来,我认为 pandas 有解决方案。给定以下代码:
In [63]: d1 = np.random.rand(3,3)
In [63]: d2 = np.random.rand(3,3)
In [64]:s1 = pandas.Series(d1,index = [['a1']*d1.shape[0],
[4]*d1.shape[0],
range(d1.shape[0])])
Out[64]:a1 4 0 [ 0.00881133 0.71344668 0.03611378]
1 [ 0.37328776 0.63195947 0.23000941]
2 [ 0.68466443 0.85891677 0.31740809]
In [65]: s2 = pandas.Series(d2,index = [['a2']*d2.shape[0],
[5]*d2.shape[0],
range(d2.shape[0])])
Out[65]:a2 5 0 [ 0.00881133 0.71344668 0.03611378]
1 [ 0.37328776 0.63195947 0.23000941]
2 [ 0.68466443 0.85891677 0.31740809]
s = s1.append(s2)
a1 4 0 [ 0.00881133 0.71344668 0.03611378]
1 [ 0.37328776 0.63195947 0.23000941]
2 [ 0.68466443 0.85891677 0.31740809]
5 0 [ 0.00881133 0.71344668 0.03611378]
1 [ 0.37328776 0.63195947 0.23000941]
2 [ 0.68466443 0.85891677 0.31740809]
如何在没有标签的情况下单独获取所有数据矩阵的列表?