【发布时间】:2018-10-29 17:17:51
【问题描述】:
这里是 Python 新手。请问我怎样才能将下面给定的数据转换成下面提到的所需格式?
来源数据:
输出数据必须如下所示:
请指教。
到目前为止我的代码:
# Transposing an excel file using python
import pandas as pd
# Location of the file
loc = ("C:\\Users\\user1\\Documents\\Python_Files\\data.xlsx")
# Reading the file
df=pd.read_excel("C:\\Users\\user1\\Documents\\Python_Files\\data.xlsx")
# Transposing the file
df.T.to_excel('C:\\Users\\user1\\Documents\\Python_Files\\data1.xlsx', index=False)
【问题讨论】:
-
请将所有相关代码作为格式化文本包含在您的问题中。
-
即使您还不确定如何以编程方式从一个到另一个,您仍然可以实际创建(示例)输入和输出列表结构。它只需要具有代表性。这有助于我们进行测试并确保我们为您提供预期的输出。图片链接可能会过期,您的问题会变得毫无意义
-
我根据您的建议在上面添加了代码。