1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
50 | 15 | 20 | 35 | 20 |
NaN | NaN | NaN | NaN | 20 |
15 | 20 | 25 | NaN | NaN |
NaN | NaN | 35 | 20 | 15 |
目标:计算在第2列中存在数字但在第1列中是NaN的单元格的数量(A)
计算在第2列中是NaN但在第1列中存在数字的单元格的数量(B)
计算在第一列中存在数字的单元格数量(C)
计算 (A+B)/(2*C)
以此类推,计算第3列、第4列……
在MatLab中,可以使用以下代码来比较列与列之间的数据缺失率:
```bash
% Get the number of rows in the data
[nRows, nCols] = size(data);
% Loop through each column
for iCol = 1:nCols
% Get the number of missing values in this column
nanCount = sum(isnan(data(:,iCol)));
% Calculate the missing value percentage
missingValuePercentage(iCol) = nanCount/nRows;
end
% Get the maximum missing value percentage
maxMissingValuePercentage = max(missingValuePercentage);
```
不知道你这个问题是否已经解决, 如果还没有解决的话: