• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Replace values in specific columns where conditions are met for rows from another dataframe

Resolved: Replace values in specific columns where conditions are met for rows from another dataframe

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have two dataframes representing two monthly datasets. I am trying to roll back the values in df1 (current month) with the values in df2 (previous month) if the value in fb is Y. The actual dataset is thousands of records long and there are 30 or so columns that need to be reset/rolled back. The double for loops in the code below return null values in df1.
If I set the right side of the assignment statement to an fixed value, the output is correct. I’ve also tried the following:
Both methods produced null values for the columns of interest in df1.
My expected output for df1 is:

Answer:

If I understood you right:

If you have better answer, please add a comment about this, thank you!

dataframe pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Kivy widget hierarchy not behaving as expected

24/03/2023

Resolved: Pandas Groupby Get Values from Previous Group

24/03/2023

Resolved: Can’t access static methods from outside until JavaScript’s static block is over?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.