Could someone please help me find a way to solve my query below? I'm more so looking for the terms to search for to solve the problem but if you know a quick-and-dirty method that would also be appreciated.
I have a matrix like the one below:
sample_1. sample_2. sample_3. sample_4.
G1 inc_1,inc_1A. *. inc_1. inc_1.
G2 inc_2. *. *. *.
G3 *. inc_3,inc_3A,inc_3B. inc_3. inc_3,inc_3A
I am looking to convert this to a matrix of counts like the one below
sample_1. sample_2. sample_3. sample_4.
G1 2 0 1 1
G2 1 0 0 0
G3 0 3 1 2
This database is quite large (about 10,000 columns and 3,000,000 rows) so I want to try avoid df.iterrows() where possible. Does anyone know how I may begin to implement this?
The "_" in the cells could be counted as all incidents have this nomenclature and a "*" means not detected (or 0).
Any help, advice, or constructive criticism is highly appreciated.