Python Forum
if nan -> find value in cell above Pandas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if nan -> find value in cell above Pandas
#1
Hi guys,

I have excel file like this:
Sometext_here
nan
nan
nan
nan
nan
nan
nan
TotallyNewThing
nan
nan
nan
How can i replace nan values? I want to replace them with VALUE above them if not nan
I am struggling with this :(

I have tried this:
for index, value in enumerate(survey):
    if value == '' or (isinstance(value, float) and  math.isnan(value)):
        value = value[index-1]
    print(value)
TypeError: 'float' object is not subscriptable
Reply


Messages In This Thread
if nan -> find value in cell above Pandas - by zarize - Mar-27-2020, 01:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,523 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  Pandas find the most often rows dervast 1 1,989 Jun-07-2019, 01:55 PM
Last Post: ichabod801
  find cell value with matching regular expression of a row in excel file hruday 4 31,222 Jul-05-2017, 01:02 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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