我有 16 个具有相同行数/列数的不同数据帧和另外 2 个具有相同形状的单独数据帧,我用来与 16 个数据帧值进行比较。
我需要同时遍历所有数据帧,并将所有行值与单独的数据帧进行比较,然后创建另一个数据帧,结果如下:
比较:sum(row_values_of_dataframe) - sum(row_values_of_reference)。在下面的示例中,单元格df_a_ref_a等于
Dataframe A (df_a)
col1 | col 2 | col 3 | col 4
1 2 3 4
2 4 6 8
[...]
Dataframe B (df_b)
col1 | col 2 | col 3 | col 4
10 5 2 1
4 4 6 2
[...]
Reference Dataframe 1 (ref_1)
col1 | col 2 | col 3 | col 4
5 5 5 5
5 5 5 5
[...]
Reference Dataframe 2 (ref_2)
col1 | col 2 | col 3 | col 4
3 3 3 3
3 3 3 3
[...]
最终数据框应为:
df_a_ref_1 | df_a_ref_2 | df_b_ref_1 | df_b_ref_2 | ....
-10 -2 -2 6 ....
0 8 -4 4
[...]
这种行为类似于zip()python 中的函数。
提前致谢,