Categorical data records membership in distinct qualitative classes rather than measured numerical quantities. Summarize its distribution with frequency counts and proportions before applying deeper analysis. section 1.1.4
When two categorical variables are analyzed together, organize their class combinations in a contingency table. Rows and columns represent classes, while each cell records the corresponding frequency. section 3.3.3
Use categorical data to:
- Count how frequently each class occurs. section 1.1.4
- Calculate proportions within a category or across a contingency-table margin. section 3.3.3
- Compare combinations of classes, such as symptoms and medical-test results. section 3.3.3
Medical-test contingency table
Represent symptoms as rows and test results as columns: No symptoms with Negative = 860, No with Positive = 90, Yes with Negative = 10, and Yes with Positive = 40. Among symptomatic cases, 40 of 50 are positive, giving an 80% conditional probability. section 3.3.3
>>> import pandas as pd
>>> contingency_table = pd.DataFrame(test_results, index = symptoms)
>>> print(contingency_table)
Negative Positive
No 860 90
Yes 10 40
Inspect the pandas contingency table showing categorical classes as labeled rows and columns with frequency counts in each cell. section 3.3.3















