standardize
standardize(array, columns=None, ddof=0, return_params=False, params=None)
Standardize columns in pandas DataFrames.
Parameters
-
array
: pandas DataFrame or NumPy ndarray, shape = [n_rows, n_columns]. -
columns
: array-like, shape = [n_columns] (default: None)Array-like with column names, e.g., ['col1', 'col2', ...] or column indices [0, 2, 4, ...] If None, standardizes all columns.
-
ddof
: int (default: 0)Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.
-
return_params
: dict (default: False)If set to True, a dictionary is returned in addition to the standardized array. The parameter dictionary contains the column means ('avgs') and standard deviations ('stds') of the individual columns.
-
params
: dict (default: None)A dictionary with column means and standard deviations as returned by the
standardize
function ifreturn_params
was set to True. If aparams
dictionary is provided, thestandardize
function will use these instead of computing them from the current array.
Notes
If all values in a given column are the same, these values are all
set to 0.0
. The standard deviation in the parameters
dictionary
is consequently set to 1.0
to avoid dividing by zero.
Returns
-
df_new
: pandas DataFrame object.Copy of the array or DataFrame with standardized columns.
Examples
For usage examples, please see http://rasbt.github.io/mlxtend/user_guide/preprocessing/standardize/