【发布时间】:2023-04-04 13:57:01
【问题描述】:
我有一个包含很多列的 df:
date risk lev chemical weight date risk lev chemical weight
15-5-16 5 Potasium 5mg 15-5-16 3 Sodium 7 mg
14-5-16 6 Potasium 10mg 14-5-16 2 Sodium 2 mg
我想重新排列一下,让每4列分成一个新行,比如df是这样的:
date risk lev chemical weight
15-5-16 5 Potasium 5mg
15-5-16 3 Sodium 7mg
14-5-16 6 Potasium 10mg
14-5-16 2 Sodium 2mg
抱歉,我没有包括我的尝试,但这是我第一次解决这个问题,不知道如何继续
【问题讨论】:
-
列名是否重复?
-
是的,它们是重复的。
标签: pandas duplicates multiple-columns reshape lreshape