[英]UnPivot a Pandas Data Set with Merge
How do I transform this starting data set into a flattened data set with a Python Pandas data frame? 如何使用Python Pandas数据框将此起始数据集转换为展平数据集?
Like this flattened data: 像这个扁平的数据:
I tried to "stack" the data and reset the index, but this produced an undesired result. 我试图“堆叠”数据并重置索引,但这会产生不希望的结果。
df = xl.parse("data")
stack = df.stack(-1).reset_index(0)
Thanks in advance for your help. 在此先感谢您的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.