normalize

Factor.normalize(data)[source]

Normalizes the data coming from this factor. A categorical factor is normalized to an array of numbers from 0 until the number of levels. A continuous factor is normalized to be between -1 and 1, using the min and max specified.

Note

This is the inverse of denormalize.

Parameters

datafloat or str or np.array(1d) or pd.Series

The data to be normalized. A continuous factor requires a float, array of floats or a series of floats. A categorical factor requires a string or series of strings.

Returns

norm_datafloat or int or np.array(1d) or pd.Series

The normalized data, in the same type as the data. Categorical inputs become integers.