Created
March 31, 2019 18:13
-
-
Save joonro/b67fd426dbc9dc7d7be151606247f0af to your computer and use it in GitHub Desktop.
[statsmodels highlight significant variables in result table] Highlight significant variables in result table using pandas.DataFrame.style #python #pandas #statsmodels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def highlight_row(row): | |
| """Highlight row with red color for variables with p < 0.05""" | |
| color = '' | |
| if row['P>|t|'] < 0.05: | |
| color = 'red' | |
| return ['color: %s' % color] * len(row.values) | |
| df_result.style.apply(custom_style, axis=1).to_excel('results.xlsx') | |
| df_result.style.apply(custom_style, axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment