You can convert all nan values to zeros using np.nan_to_num() and then
proceed further. Demo:
>>> data
array([[ 5.1, 3.5, 1.4, 0.2],
[ 4.9, 3. , nan, 0.2],
[ 4.7, 3.2, 1.3, nan],
[ nan, 3.1, 1.5, 0.2]])
>>> np.cov(data.T)
array([[ nan, nan, nan, nan],
[ nan, 0.04666667, nan, nan],

The problem seems to be the K = C2^(16/57). Taking the root of a
matrix is not trivial and solutions don't always exist. That's why
MATLAB cannot resolve this expression. Try for example:
A = syms('A',[3,3]); % create 3x3 symbolic matrix
B = A^(1/3); % calculate the 3rd root of A
The result will be
ans = matrix([[a1_1, a1_2, a1_3], [a2_1, a2_2, a2_3], [a3_1, a3_2,
a3_3]])^(1/3)

Assuming that the block of columns are based on the first two
characters, i.e. A1, A2, we can split this into different blocks by
using substr to extract the first two characters from the column names
and use this as index to split. Then, we can either use apply with
range and diff to get the result or use pmax and pmin.
indx < substr(colnames(df), 1,2)
If the grouping is not based on t
