# sum

## How can I write a function that finds any and all elements of a list that add to a target?

How can I write a function that finds any and all elements of a list that add to a target? Question: I have been hired to reconcile years of financial records that have quite large discrepancies. The statements are listed in excel and include a name and figure of the transaction (either positive or negative …

## 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", …

## Harmonic Function (Square Wave Fourier Series) in Python using Nested Loops and Lists

Harmonic Function (Square Wave Fourier Series) in Python using Nested Loops and Lists Question: Apologies for the lack of in-line pictures, I am a first time poster. I am trying to plot a square wave via a Fourier Series using nested loops with matplotlib. The square wave is given by the function: I take an …

## 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]} …

## 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 …

## 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", …

## After subsetting a dataframe, how to add a column that will sum only specific columns in the subset (row wise)?

After subsetting a dataframe, how to add a column that will sum only specific columns in the subset (row wise)? Question: I’ve searched a lot, including in suggested past questions, and didn’t find an answer. Coming from R and tidyverse and new to Python and pandas. I want to add a column to a subset …

## 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(): …