Crosstab and Counting Pairs
crosstab counts how often combinations of two columns occur.
Example
import pandas as pd
import numpy as np
x = pd.DataFrame({'sex': ['F', 'M', 'F', 'F'], 'ans': ['y', 'y', 'n', 'y']})
print(pd.crosstab(x['sex'], x['ans']))Result
ans n y sex F 1 2 M 0 1
Exercise
Count combinations.
pd.(a, b)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.