Created
October 21, 2018 16:19
-
-
Save joonro/d16a75abb254ab4555fbf7ba7c8e68e9 to your computer and use it in GitHub Desktop.
[Pandas DataFrame for output printing] #python
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 print_results(mean_post, std_post): | |
| """Create Pandas DataFrame with results""" | |
| num_digits = 3 | |
| result_table = mean_post.round(num_digits).astype(str) | |
| str_std_post = std_post.round(num_digits).astype(str) | |
| t_stat = mean_post / std_post | |
| for col in result_table: | |
| """Add more 0's for 0.0""" | |
| result_table[col] = result_table[col].str.replace('(\.\d{1})$', '\g<1>' + '0' * (num_digits - 1)) | |
| str_std_post[col] = str_std_post[col].str.replace('(\.\d{1})$', '\g<1>' + '0' * (num_digits - 1)) | |
| result_table[abs(t_stat) >= 1.96] += '*' | |
| result_table[abs(t_stat) < 1.96] += ' ' | |
| for col in result_table: | |
| """Add STD""" | |
| result_table[col] += ' (' + str_std_post[col] + ')' | |
| return result_table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment