counter

How to calculate the maximum sum in a reverse way in pandas list

How to calculate the maximum sum in a reverse way in pandas list Question: I have this list: balance = [300,400,250,100,50,1,2,0,10,15,25,20,10,1,0,10,15] I need to calculate the maximum consecutive increase in balance over a certain period of time. The first element on the right is the most recent. For example, I need to calculate the maximum …

Total answers: 2

Counting elements with tolerance

Counting elements with tolerance Question: I have a long list of values (here below a shortened version) that I need to count: ed = [ 0.52309 , 3.1443 , 16.5789 , 24.0643 , 9.70981 , 1.71983 , 16.3453 , 14.1901 , 22.0353 , 1.71983 , 15.0469 , 13.98 , 11.4753 , 32.7859 , 9.7098 , …

Total answers: 1

Use Counter to count unique values in multiple lists

Use Counter to count unique values in multiple lists Question: I have a list of lists and I’m trying to use Counter to get the number of unique words across all of the lists. [[‘My’, ‘name’, ‘is’, ‘Joe’], [‘My’, ‘name’, ‘is’, ‘Sally’], [‘My’, ‘name’, ‘is’, ‘Mike’]] If it were just the first list I think …

Total answers: 2

remove entry in counter object if value meets condition

remove entry in counter object if value meets condition Question: Is there a way to remove entries from a counter object if the value matches a certain condition. For example: Counter({‘a’: 1142,’b’:1004,’c’:100,’d’:5}) I want to drop all indexes where it is less than 1000, so I just have ‘a’ and ‘b’ left. I know I …

Total answers: 2

Counter of lists of lists

Counter of lists of lists Question: I have a big dictionary coming from a simulation loop that looks something like this: my_dict = { ‘a’: { 1: [[1,2,3], [1,2,3], [1,2,3], [1,3,5]], 2: [[2,44,57,18], [2,44,57,18], [2,44,57,23], [2,44,57,23]]}, ‘b’: { 3: [[3,67,50], [3,67,50], [3,36]], 4: [[4,12,34], [4,12]]}} The structure is itself odd but I couldn’t figure any …

Total answers: 1

Python Pandas DataFrame: conditional column based on other column values

Python Pandas DataFrame: conditional column based on other column values Question: Description of the problem: I’am trying to simulate a machine whose operation mode "B" occurs if "VALUE" is greater or equal to 5 in the last 3 previous time steps- which means "VALUE">= 5 for at least 3 minutes.The Operation mode "B" keeps to …

Total answers: 1

Python Pandas Dataframe: conditional counters of one and zeros values

Python Pandas Dataframe: conditional counters of one and zeros values Question: I want to add two columns in my dataframe with the following function using python: "counter1": it counts the number of the ones in the column "case1-0". (cumulative sum of the ones) "counter2": it counts the number of the zeros in the column "case1-0" …

Total answers: 1

Python Pandas DataFrame: Add a counter based on condition for 2 cases

Python Pandas DataFrame: Add a counter based on condition for 2 cases Question: I want to produce two counters ("counter1", "counter2") in the following dataframe examples (cases: 1 and 2) using python functions with these characteristics: case 1: "counter1": it counts the number of the zeros in the column "case1-0". (cumulative sum of the zeros) …

Total answers: 1

How to increase count if function called by another function in Python

How to increase count if function called by another function in Python Question: I am trying to count all tokens given by func1 and print out the result from func2. The problem is that each time func2 gets called the counter does not update for natural reasons because we call the function over and over …

Total answers: 2

Updating A List Word Counter

Updating A List Word Counter Question: I’m creating a program that counts letters. I created two dictionaries that both have the same word and, because they are the same exact word, both have the same counter. I want to know how to merge the two dictionaries so that it updates the counters as well, but …

Total answers: 2