General remark
When choosing an approach to filling in empty values, it is necessary to consider what will be done with the data after filling. If you plan to read the correlation, be sure to look at the basis of what idea the correlation is considered.
Specifically in this matter
For numeric types, it is probably worth filling the gaps with the average, because then the correlation between the binary and real variables will be considered, and this is done through the difference between the mat. expectations ( E[X1|X2=1] - E[X1|X2=0] ), that is, it is important to keep the mat. waiting unchanged.
For categorical traits, the correlation with a binary trait can be calculated using Cramer’s V coefficient:
chi2 = stats.chi2_contingency(confusion_matrix)[0] n = confusion_matrix.sum() return np.sqrt(chi2 / (n*(min(confusion_matrix.shape)-1)))
That is, the input is the table of contingency. If there is enough data, then I would exclude all omissions. The second approach is to introduce a new category for each feature, for example, "no_value" , but in this case it will also appear in the contingency table.