Mar-01-2022, 03:41 PM
This is a good example of where the very last line of the error is sufficient to show the cause of the problem (although not necessarily to fix it!).
You are trying to work out the correlation coefficient of a column that includes strings.
numpy is trying to calculate the correlation coefficient of each pair of columns, but column 1 (functional groups) is all strings, so when numpy tries to compute the average, it adds up all those strings (concatenation) to get one large string, then tries to divide by the number of rows.
I'm not sure how to fix that, there doesn't seem to be any facility in
By the way, the code you have copied and pasted here seems to be different from the code in your screen shot.
TypeError: unsupported operand type(s) for /: 'str' and 'int'
You are trying to work out the correlation coefficient of a column that includes strings.
numpy is trying to calculate the correlation coefficient of each pair of columns, but column 1 (functional groups) is all strings, so when numpy tries to compute the average, it adds up all those strings (concatenation) to get one large string, then tries to divide by the number of rows.
I'm not sure how to fix that, there doesn't seem to be any facility in
np.corrcoef
to select which columns (or rows) are used.By the way, the code you have copied and pasted here seems to be different from the code in your screen shot.