Python Forum
[pandas] Find the first element that is -1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[pandas] Find the first element that is -1
#2
Do the values following the first -1 always equal -1 or can they vary? For example:

25 30 22 87 -1 -1 # Always -1
25 30 22 87 -1 6 # Not always -1
If it's the former, you can use filter to find all values that do not equal -1 and then use len() on the result. Otherwise, I'm not sure you'll be able to avoid a loop.
Reply


Messages In This Thread
RE: Find the first element that is -1 - by stullis - Jun-13-2019, 04:47 PM
RE: Find the first element that is -1 - by ThomasL - Jun-14-2019, 04:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Referring to a specific element in Pandas Dataframe Helmi 2 3,272 Mar-17-2019, 09:12 PM
Last Post: Helmi

Forum Jump:

User Panel Messages

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