I am new to Python and am currently facing a problem that I cannot solve. I really hope you can help me. English is not my native language, so I'm sorry if I can not express myself properly.
Let's say I have a simple data frame with two columns:
index Num_Albums Num_authors
0 10 4
1 1 5
2 4 4
3 7 1000
4 1 44
5 3 8
Num_Abums_tot = sum(Num_Albums) = 30
I need to make a cumulative sum of data in Num_Albumsuntil a certain condition is reached. Register the index in which the condition is satisfied and get the corresponding value from Num_authors.
Example: cumulative amount Num_Albumsuntil the amount is 50% ยฑ 1/15 of 30 (-> 15 ยฑ 2):
10 = 15ยฑ2? No, then continue;
10+1 =15ยฑ2? No, then continue
10+1+41 = 15ยฑ2? Yes, stop.
The condition achieved with index 2. Then we get Num_authorsin this index:Num_Authors(2)=4
, , pandas, , while/for....
[ , ( , , , 4 , 1, = , 2, 3 4)].