【发布时间】:2021-04-29 18:01:24
【问题描述】:
我确实有以下数据框:
1 2 3 4 5 6
0 NaN NaN NaN a b c
1 NaN NaN NaN d e f
2 NaN NaN NaN g h i
0 1.0 2.0 3.0 -5.0 -4.0 -36.0
1 4.0 5.0 6.0 -32.0 -31.0 -120.0
2 7.0 8.0 9.0 102.0 126.0 3.0
这是四个 Dataframe 的乘积,因此每个季度(大小 3x3)也可以作为一个独立的 pandas 数据框使用。 我需要一个结构如下的数据框:
1 2 3 4 5 6
1 1 a 2 d 3 g
2 4 b 5 e 6 h
3 7 c 8 f 9 i
用文字描述:
so the first element of the third row is followed by the first element of the third Column.
second element of the third row ... second element of the third Col
third element of the third row ... third element of the third C..
so the first element of the fourth row is followed by the first element of the fourth Column.
second element of the fourth row ... second element of the fourth Col
third element of the fourth row ... third element of the fourth C..
so the first element of the fifth row is followed by the first element of the fifth Column.
second element of the fifth row ... second element of the fifth Col
third element of the fifth row ... third element of the fifth C..
欢迎和赞赏任何想法。请考虑:
- 6x6 是示例性数据帧,其差异可能为 4x4 或大于 6x6
- 8x4 也可能发生
更新: 好吧,也许它可以使用 df.T(转置)数据帧右上角(abc..hi)并通过一个循环,该循环放置一列 df(下 lfet),然后是一列转置的右上数据帧。因为我现在要上班了,我明天试试看,然后再更新我的帖子
【问题讨论】:
-
好吧,也许可以使用 df.T(转置)Dataframe 右上角(abc..hi)和
标签: python-3.x pandas dataframe itertools