The following is a small extract of a large excel table with many weeks of data:
Q
+--------------+--------------------------+------------+
| Keyword | searches | KW45 |
+--------------+--------------------------+------------+
| durni coat | 110 | 1 |
| gliss coat | 40 | 2 |
| hart coat | 70 | 7 |
| kepla coat | 50 | 3 |
| lasox coat | 0 | 1 |
| magna coat | 10 | |
| magoxid coat | 10 | 2 |
| plasma coat | 50 | 3 |
| selga coat | 0 | 1 |
| sila coat | 0 | 25 |
| temp coat | 10 | 50 |
+--------------+--------------------------+------------+
Currecntly I use these functions in Excel in columns C :
=COUNTIFS(Q:Q;"=1";;INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
=COUNTIFS(Q:Q;"=2";;INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
=COUNTIFS(Q:Q;"=3";;INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
=COUNTIFS(Q:Q;">=4";Q:Q;"<=5";INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
=COUNTIFS(Q:Q;">=6";Q:Q;"<=10";INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
=COUNTIFS(Q:Q;">=11";Q:Q;"<=20";INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
=COUNTIFS(Q:Q;">=21";Q:Q;"<=30";INDEX($Q:$T;;MATCH(C1;$Q$1:$T$1;0));">0")
and so on....
which match the week and postion range to create the following table:
| B | C |
| Position | KW45 |
|------------|------|
| Pos. 1 | 3 |
| Pos. 2 | 2 |
| Pos. 3 | 2 |
| Pos. 4-5 | 0 |
| Pos. 6-10 | 1 |
| Pos. 11-20 | 0 |
| Pos. 21-30 | 1 |
| Pos. 31-40 | 0 |
| Pos. 41-50 | 1 |
How would I go about to acheive the above functuon in pandas?
My goal ist to count the number of occurances of:
value 1 in column Q
value 2 in column Q
value 3 in column Q
value range 4-5 in column Q
value range 6-10 in column Q
value range 11-20 in column Q
and so on...