statsmodels.multivariate.factor.FactorResults.get_loadings_frame#
- FactorResults.get_loadings_frame(style='display', sort_=True, threshold=0.3, highlight_max=True, color_max='yellow', decimals=None)[source]#
Get loadings matrix as DataFrame or pandas Styler
- Parameters:
- style{‘display’, ‘raw’, ‘strings’},
optional Style to use for display. The default is ‘display’.
- ‘raw’ returns just a DataFrame of the loadings matrix, no options are
applied
‘display’ add sorting and styling as defined by other keywords
- ‘strings’ returns a DataFrame with string elements with optional sorting
and suppressing small loading coefficients.
- sort_bool,
optional If True, then the rows of the DataFrame is sorted by contribution of each factor. applies if style is either ‘display’ or ‘strings’
- threshold
float,optional If the threshold is larger than zero, then loading coefficients are either colored white (if style is ‘display’) or replace by empty string (if style is ‘strings’).
- highlight_maxbool,
optional This add a background color to the largest coefficient in each row.
- color_max
str,optional default is ‘yellow’. color for background of row maximum
- decimals
int,optional If None, then pandas default precision applies. Otherwise values are rounded to the specified decimals. If style is ‘display’, then the underlying dataframe is not changed. If style is ‘strings’, then values are rounded before conversion to strings.
- style{‘display’, ‘raw’, ‘strings’},
- Returns:
Examples
>>> mod = Factor(df, 3, smc=True) >>> res = mod.fit() >>> res.get_loadings_frame(style='display', decimals=3, threshold=0.2)
To get a sorted DataFrame, all styling options need to be turned off:
>>> df_sorted = res.get_loadings_frame(style='display', ... highlight_max=False, decimals=None, threshold=0)
Options except for highlighting are available for plain test or Latex usage:
>>> lds = res.get_loadings_frame(style='strings', decimals=3, ... threshold=0.3) >>> print(lds.to_latex())