Python Forum
Cmparing columns in dataframe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Cmparing columns in dataframe (/thread-29087.html)



Cmparing columns in dataframe - Rejoice - Aug-17-2020

hi,
I have two dataframes df1 & df2. Both df1 & df2 have same index. I want to compare 2nd column of df1 with 3rd column of df2 and if it is equal or greater or lesser and then perform certain set of mathematical operations on other two columns one each in df1 & df2 and then store the results obtained in df3. df3 will also have the same index. how do i go about it. is it possible to make such comparison and calculations.

I tired np.where, however i am not aware how do i make a bigger calculations if the result is true and then store the result in another dataframe.

Thanks in advance
Rejoice