我要使用python在excel工作表中有两列和多行,我想堆叠数据(类似于我们在minitab中的操作方式)
这就是我的数据的样子
CmpTimestamp = []
for index,element in enumerate(1stColumn1stDataset):
for idx,el in enumerate(1stColumn2ndDataset):
if truncate(element*100)/100 == truncate(el/10)/100:
CmpTimestamp.append(truncate(element*100)/100)
我已经尝试过使用堆栈函数,但是发生的是数据存储在索引值中
CmpTimestamp
预期结果
Adults-------------------------------->Children
Did Not Purchase------------------>Did Not Purchase
Did Not Purchase------------------>Purchased
Did Not Purchase------------------->Did Not Purchase
Did Not Purchase------------------->Purchased
Did Not Purchase------------------>Did Not Purchase
Did Not Purchase------------------->Did Not Purchase
Did Not Purchase-------------------->Did Not Purchase
Did Not Purchase------------------->Purchased
Did Not Purchase------------------->Did Not Purchase
Did Not Purchase------------------->Did Not Purchase
Did Not Purchase------------------->Did Not Purchase
Did Not Purchase-------------------->Did Not Purchase
Purchased-------------------------->Did Not Purchase
Purchased-------------------------->Did Not Purchase
Purchased-------------------------->Did Not Purchase
Did Not Purchase-------------------->Did Not Purchase
Did Not Purchase-------------------->Did Not Purchase
Did Not Purchase--------------------->Did Not Purchase
Did Not Purchase-------------------->Did Not Purchase
答案 0 :(得分:0)
df_adult = df[['Adults']].copy()
df_child = df[['Children']].copy()
df_final = df_adult.append(df_child,ignore_index=True)