sum

Sum categories by unique values in list in python

Sum categories by unique values in list in python Question: I have this list: [(‘2023-03-15’, ‘paris’, ‘flight’, 4), (‘2023-03-21’, ‘berlin’, ‘flight’, 2), (‘2023-03-01’, ‘madrid’, ‘drive’, 10), (‘2023-03-04’, ‘madrid’, ‘cycling’, 3), (‘2023-03-08’, ‘rome’, ‘train’, 9), (‘2023-03-11’, ‘amsterdam’, ‘flight’, 5), (‘2023-03-14’, ‘london’, ‘boat’, 1)] How do you reproduce the same list syntax summing similar activities like "flight", …

Total answers: 3

Pandas: Find the left-most value in a pandas dataframe followed by all 1s

Pandas: Find the left-most value in a pandas dataframe followed by all 1s Question: I have the following dataset data = {‘ID’: [‘A’, ‘B’, ‘C’, ‘D’], ‘2012’: [0, 1, 1, 1], ‘2013’: [0, 0, 1, 1], ‘2014’: [0, 0, 0, 1], ‘2015’: [0, 0, 1, 1], ‘2016’: [0, 0, 1, 0], ‘2017’: [1, 0, 1,1]} …

Total answers: 1

count how many times the column ratio is bigger than 0.05 and column dif is between 15 and 30

count how many times the column ratio is bigger than 0.05 and column dif is between 15 and 30 Question: Datetime ratio dif 2022-06-09 12:33:00 -0.3861241598107547 -299.50183804712964 2022-06-09 12:34:00 -0.360130489922861 -274.88184087028105 2022-06-09 12:35:00 -0.22108950904852795 -166.02672464097395 2022-06-09 12:36:00 -0.18316426991752388 -135.2928226604197 2022-06-09 12:37:00 -0.09932437001820388 -72.14644129886278 2022-06-09 12:38:00 -0.0820362738010348 -58.58522049972339 2022-06-09 12:39:00 -0.04310125282586597 -30.25449340858836 2022-06-09 12:40:00 -0.48650055935157194 -335.5773828284086 …

Total answers: 1

How to sum elements of a list encoded as strings with numbers

How to sum elements of a list encoded as strings with numbers Question: There is a list with duplicate word elements with a number at the end of them. I want to sum the duplicate’s numbers, remove the duplicates and print words with sum of numbers but I don’t know how… Input: a = ["mango3", …

Total answers: 1

What do i have to do if i want to Sum my result using Python?

What do i have to do if i want to Sum my result using Python? Question: import string dict = {} bool = False user_string = input("Bitte gebe hier die Buchstaben ein, welche du Summieren möchtest:") String_Num = "" for i, char in enumerate(string.ascii_lowercase): dict[i] = char # This is dictinoary. for val in user_string.lower(): …

Total answers: 1

Multiplying Values from two different Dictionaries

Multiplying Values from two different Dictionaries Question: I have two dictionaries which I need to multiply and get the total of, both with the same keys (I need the total of the stock and price of some items). # Create a list "menu" with 4 items menu = ["sandwich", "burger", "fish", "chips"] # Create a …

Total answers: 4