Target encoding replaces a category with a statistic of the target, often its mean, for that category. It handles variables with many levels well, but easily leaks the target: it must be computed in cross-validation with smoothing. scikit-learn's TargetEncoder does it this way.
Example
TargetEncoder(smooth='auto')