Python Forum
Cmparing columns in dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cmparing columns in dataframe
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Running search/replace across Polars dataframe columns efficiently hobbycoder 3 2,261 Oct-28-2024, 03:18 AM
Last Post: hobbycoder
  Converting a json file to a dataframe with rows and columns eyavuz21 13 13,963 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  Nested for loops: Iterating over columns of a DataFrame to plot on subplots dm222 0 2,935 Aug-19-2022, 11:07 AM
Last Post: dm222
  Apply fillna to multiple columns in dataframe rraillon 2 3,876 Aug-05-2021, 01:11 PM
Last Post: rraillon
  How to rename dataframe columns based on the content in an index? ar_mahdavi 2 3,267 Jun-07-2021, 06:09 AM
Last Post: ricslato
  How to sum across variable columns in a dataframe rennerom 2 4,049 Jan-31-2021, 05:44 PM
Last Post: rennerom
  How to split dataframe object rows to columns Mekala 1 3,867 Nov-12-2020, 04:18 PM
Last Post: michael1789
  convert list to five columns dataframe in sequence tonycat 2 3,236 Sep-29-2020, 06:47 AM
Last Post: tonycat
  How to melt dataframe multiple columns to one column Mekala 1 3,824 Sep-24-2020, 08:32 PM
Last Post: scidam
  Concatenate two files with different columns into one dataframe moralear27 1 2,705 Sep-11-2020, 10:18 PM
Last Post: moralear27

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020