Python Forum
count occurrence of numbers in a sequence and return corresponding value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
count occurrence of numbers in a sequence and return corresponding value
#7
(May-20-2019, 05:28 PM)michalmonday Wrote: Now I'm even more confused to be honest.

So
X = [5,5,5,5,5]
results in:
Y = [1,1,1,1,1]

but
X = [4,4,4,4,4]
results in
Y = [3,3,3,3,3]

Another thing that is confusing me is that:
X = [1,2,3]
results in
Y = [1,2,3]

but
X = [6,6,6]
results in
Y = [4,6,7]

And in the first example it used to be:
X = [3,4,5]
resulting in
Y = [0,0,0]


What's the logic behind it?

i suggest to stick the latest sample data that I showed. basically i am observing data from a machine which will spit out numbers in X and when these numbers repeat themselves, it means something is wrong and it will then spit out the failure information in Y so that is why I need to know what is Y when X has repeated occurrences because the failure description is tied to the number being shown in Y. The reason why I need the information only once is because the failure in Y can also repeat itself at a later timepoint so even if I used the groupby method for Y, it will not separate these occurrences, for example Y may have [5,5,5,5,5,1,2,3,5,5,5,5,5,0,1,3,3,3,3,3] so I need to know that failure 5 occurred twice in this time series and not the sum of it. I hope this is clear and thanks for your patience.
Reply


Messages In This Thread
RE: count occurrence of numbers in a sequence and return corresponding value - by python_newbie09 - May-20-2019, 06:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 8 16,255 Jan-05-2024, 08:30 PM
Last Post: sgrey
  Row Count and coloumn count Yegor123 4 1,511 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  How to get unique entries in a list and the count of occurrence james2009 5 3,154 May-08-2022, 04:34 AM
Last Post: ndc85430
  Selecting the first occurrence of a duplicate knight2000 8 5,539 May-25-2021, 01:37 AM
Last Post: knight2000
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 2,672 Nov-23-2020, 05:15 PM
Last Post: cananb
  Checking for one or more occurrence in a list menator01 3 2,809 May-18-2020, 06:44 AM
Last Post: DPaul
  Return prime numbers from range krzyfigh 2 2,033 Apr-20-2020, 08:08 PM
Last Post: krzyfigh
  Define a range, return all numbers of range that are NOT in csv data KiNeMs 18 7,508 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  How to count and order numbers in a list rachyioli 2 2,684 Aug-21-2019, 10:51 AM
Last Post: perfringo
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,932 May-09-2019, 12:19 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

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