【发布时间】:2020-11-05 19:24:42
【问题描述】:
Q1) 有没有办法在 DataFrame 中将行设置为列行?
(DF) (DF)
A B C D a b c d
0 a b c d pandas function 0 4 5 3 6
1 4 5 3 6 ==========================> 1 3 2 5 3
2 3 2 5 3 0-idx row to columns-row 2 4 7 9 0
3 4 7 9 0
Q2) 如何通过将任何索引行设置为 column_row 从 Excel 文件中获取 DataFrame?
(EXCEL or CSV) (DF)
A B C D a b c d
0 a b c d pd.read_excel() 0 4 5 3 6
1 4 5 3 6 ==========================> 1 3 2 5 3
2 3 2 5 3 0-idx row to columns-row 2 4 7 9 0
3 4 7 9 0
【问题讨论】:
-
如何将行设置为标题:stackoverflow.com/questions/26147180/… 第二次读取时指定
header=true -
谢谢,我看到了你的链接,我可以通过添加参数'header'来解决Q2。
标签: python excel pandas dataframe csv