Created
March 12, 2019 02:58
-
-
Save panicpotatoe/5adb4139d59c73463bad4ab11974a506 to your computer and use it in GitHub Desktop.
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
| """ | |
| Calculate the "expected" table: | |
| "Expected" table can be calculated using below formula: | |
| total_rows x total_columns / total_observations | |
| And these factors can be get by: | |
| - total_rows = voter_tab["row_totals"] | |
| - total_columns = voter_tab["col_totals"] | |
| - total_observations = 1000 | |
| Please note that the "loc" function in below code is used to switch the | |
| index base on column name to row name | |
| """ | |
| expected = np.outer(voter_tab["row_totals"][0:5], | |
| voter_tab.loc["col_totals"][0:3]) / 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment