我想在Excel中复制列的右侧单元格值。它不包含标题
我使用的是python3.6,Pandas模块
我的输入文件是这样的
Name Hierarchy Module Values
Name1 top top 0
Name11 M1 m11 1
Name11 M1 m12 2
Name12 M2 m21 3
Name12 M2 m22 4
Name13 M3 m31 5
Name13 M3 m32 6
Name13 M5 m33 7
Name13 M6 m34 8
Name2 top2 top2 9
Name21 M1 m11 10
我想复制M*(M1, M1, M2,M2, M1 )
和m* (m11, m12, m21, m22m m31, m32, m33, m34)
预期产量:
Name Hierarchy Module Next_line_module Values
Name1 top top 0
Name11 M1 m11 1
Name11 M1 m12 2
Name12 M2 m21 3
Name12 M2 m22 4
Name13 M3 m31 5
Name13 M4 m32 6
Name13 M5 m33 7
Name13 M6 m34 8
Name2 top2 top2 9
Name21 M1 m11 10
你能帮帮我吗
您可以使用
pd.read_fwf
尝试此操作:输出:
如果您最初没有在答案中打印的字符串格式的数据,但在数据框中,您可以尝试:
其输出为:
相关问题 更多 >
编程相关推荐