-1
$\begingroup$

Suppose we have a dataframe df in python, with numerical and categorical variables.

For Numerical, when do we replace by mean and when by median.

For Categorical, is there an approach which needs to be followed.

$\endgroup$

closed as primarily opinion-based by Stephen Rauch, timleathart, Icyblade, Sean Owen Oct 9 '17 at 15:30

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

1
$\begingroup$

In my experience, there is no one correct answer to this question. It depends mostly on your problem itself. I'll base my answer on most general cases though.

For most Numerical data, a parametric method is the best way to go. If you have some sample data which you can use as a baseline. Try using a parametric method such as Normal distribution, Exponential Distribution or so depending on your model.

For categorical data, you can try various oversampling techniques or undersampling techniques. Methods such as SMOTE, ADASYN etc can be used to fill in some missing values.

However, these methods are just general cases. But as aforementioned it depends more on your model and the type of data you are working with. It could be that maybe you are using scientific data and you don't need to generate synthetic data so based on how much data you have available you can discard the missing rows.

All such nuances come into play before making the most optimal decision for your data model.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.