我有两只大熊猫。系列...
import pandas as pd
import numpy as np
length = 5
s1 = pd.Series( [1]*length ) # [1, 1, 1, 1, 1]
s2 = pd.Series( [2]*length ) # [2, 2, 2, 2, 2]
...而且我想将它们与前两个系列的交错值合并成一个系列。像这样的东西:[1、2、1、2、1、2、1、2、1、2]
In[27]:pd.Series(np.column_stack((s1,s2)).flatten())
Out[27]:
0 1
1 2
2 1
3 2
4 1
5 2
6 1
7 2
8 1
9 2
dtype: int64
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句