Skip to content

Instantly share code, notes, and snippets.

@panicpotatoe
Last active March 12, 2019 03:03
Show Gist options
  • Select an option

  • Save panicpotatoe/5d98c73c8673e8ad08bde4e76d41f4d5 to your computer and use it in GitHub Desktop.

Select an option

Save panicpotatoe/5d98c73c8673e8ad08bde4e76d41f4d5 to your computer and use it in GitHub Desktop.
# STEP 2: GET THE "OBSERVED" TABLE AND "EXPECTED" TABLE
"""
Calculate the "observed" table:
"Observed" table can be extracted from our CrossTab by exclude the row_totals and col_totals
You can see row_totals is in the index of 4 (in column)
and col_totals is in the index of 6 (in row).
So [0:5, 0:3] means "we will take the rows from 0 index to 5 index
and columns from 0 index to 3 index and assign to new CrossTab
that named [observed]"
"""
observed = voter_tab.iloc[0:5, 0:3]
# You can check the data of observed table by calling it
observed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment