excel to python median if calculation?

Occasional Visitor

excel to python median if calculation?

 srno sku rp sp lp 1 watch34 2799 3243 2524 2 watch34 2799 324 23423 3 watch34 2799 3432 2343 4 watch34 2799 3243 23423 5 - 3243 3243 234 6 watch34 2799 3244 3242 7 watch25 3243 3243 2343 8 handbag25 3242 3242 23423 9 handbag25 3242 245 3243 10 watch34 2799 2355 3232 11 - 3243 2345 32432 12 watch34 2799 23 3243 13 watch34 2799 454 23434 14 - 3243 35443 2343 15 handbag25 3242 4543 32434

={MEDIAN(IF(\$B\$2:\$B\$16=B2,\$D\$2:\$D\$16))}
={MEDIAN(IF(\$B\$2:\$B\$16=B3,\$D\$2:\$D\$16))}
={MEDIAN(IF(\$B\$2:\$B\$16=B4,\$D\$2:\$D\$16))}
so on column of median
calculation of (median if) till now using above formula but it takes so much time on excel while doing on lots of data in row how can we convert this into python to make calculation faster

Re: excel to python median if calculation?

Hello @Dynamo14324
Just playing the Devil's advocate how do you know that Python will be any faster?
What I would suggest is to figure out what is going on to slow down this process and then figure out how to speed it up. I tried this on my development machine (3.07 gigahertz Intel Xeon X5675 (2 installed) and MS-Excel is using all 24 Hyper-threads) and it took a millisecond! No I did not measure the time, I just guesstimated. Tell us what version of MS-Excel are you using and stuff like that and lets see if we can help you speed this up.