Looping through a dataframe and add values to a dictionary - python-3.x

I'm trying to loop through a dataframe. All the columns are numeric. I want to get the sum of each column and add it to a dictionary that has the name of the column as the key and the sum of the column as the value.

Related

sumifs in excel where the criteria is a range possible?

assume a table where one column has values T1...Tn. how would I get the sum of another column where the corresponding T value is a set?
=SUMIFS(...,Sheet1!$D$1:$D$250,{"T1","T2","T3","T4","T5"})
I tried this but it is only picking values corresponding to T1

How to merge to two rows if two cols contain same value

I want to merge excel rows comparing values of two columns: Column A and Column B.
If the values of Col A and Col B are same it should be merged with other rows(can be multiple rows) which has the same values in Col A and Col B.
Values in Third column should be appended with comma to the merged row.
Please refer this image to get more clarity, it is easier to explain with an example:
As per my below screenshot try-
E2=UNIQUE(A2:B4)
G2=TEXTJOIN(", ",TRUE,IF($A$2:$A$4&$B$2:$B$4=E2&F2,$C$2:$C$4,""))

How to split Excel row into multiple based on value in cell

I would like to split the rows out in the first table based on comma separated values in Column C.
So columns A,B,D,E would be duplicated for each comma separated value in column C.
So the data would result in the table below.
Thanks
Here's an algorithmic approach you can try
Get a reference to your data range
Loop over the rows in that range
Since you're going to be adding rows, loop bottom to top
For each row
Split the value in column C
If the resulting array has > 1 values, insert rows for the new values
Copy Values into the new rows
Transpose the Split array into column C
Repeat

Excel - How can I extract unique values from one column to an another column without using array formulas and helper columns?

I have one sheet named student list that contains 'Job Title' column and I want to extract unique values from that column to an another column in a different sheet but the condition is NOT to use array formulas and helper columns.
Use following formula (Non Array) to extract unique values from a list.
=IFERROR(INDEX($C$4:$C$20,MATCH(0,INDEX(COUNTIF($E$3:E3,$C$4:$C$20),0,0),0)),"")

Excel: How to return a unique list array as a result of a two column lookup

I have two columns of equal number of rows with repeating values in each. The first column is in order by number, the second column is secondarily ordered by number. I want a list of all the unique values that pair with a given value from the first column.
Example:
Col A: {1;1;1;1;2;2;2;2;3;3;3;3;4;4;4;4}
Col B: {a;a;b;c;a;b;b;c;.....etc}
I want to specify a cell that contains the value in Col A, say "2", and return the unique values as an array into a list of cells the values from Col B. So: {a;b;c}.
Right now I have a column indexed array formula using Small to list through the full set of B matches, then I have a second column indexed array formula to sort out the unique values from that, but I can't seem to find a way to make it one formula.
So now I have (say col C):
{=INDEX(A:A&B:B,SMALL(IF(A:A=A1,ROW(A:A)),ROW(1:1),2)}
which I fill down to the number of rows that covers all the values for a given A value.
Then I have another column to find the uniques:
{=IFERROR(INDEX(C:C,MATCH(0,COUNTIF($D$1:D1,C:C),0)),"")}
which I fill down to the number of rows that covers the unique values

Resources