I have an excel file with 2 tab sheets(A and B). Each tab sheets has 10 columns corresponding to 10 different parameters. I need iterate through both tab sheets and multiply column 1 in tab sheet A with column 1 in tab sheet B, multiply column 2 in tab sheet A to column 2 in tab sheet b, etc.. therefore I will obtain 10 columns corresponding to the 10 operations. How to I write that in Pandas? Thanks in advance for your help
One of the comments had it pretty close.
dfs = pd.read_excel('test.xlsx', sheet_name = None, header=None)
dfs is now an ordered dictionary that looks like this:
OrderedDict([('a', 0 1 2
0 1 2 3
1 4 5 6), ('b', 0 1 2
0 7 8 9
1 10 11 12)])
You can get the multiplication like the comment suggests.
dfs['a'] * dfs['b']
Output:
0 1 2
0 7 16 27
1 40 55 72
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.