• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Replace values in Columns with previous cell value

Resolved: Replace values in Columns with previous cell value

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

Question:

I want to replace values from a column in a dataframe to NaN and then replace Nan to the value from the previous row. This is the code that I’m currently using:


And this is how my data looks like:


Now this is the desired output:
enter image description here
Hope you all can help me :c

Answer:

IIUC, one way using ffill with groupby.transform:
Output:

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

pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to resolve LNK2001 in c++ projects

26/03/2023

Resolved: How to correctly initialize vector of number in Typescript

26/03/2023

Resolved: mysql calculating to get profit or loss from 2 tables ( Purchases and Sales) in FIFO mode

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

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