text_html_output_1.png
import pandas as pd

df = pd.read_csv('../input/bank-marketing/bank-full.csv')
marketing = df[['campaign', 'y']]
marketing.sample(5)

df_bank = marketing.groupby(['y']).apply(lambda x: x.sample(n=199, random_state=123))
df_bank.drop(columns='y', axis=1, inplace=True)
df_bank.reset_index(inplace=True)
df_bank.drop(columns='level_1', axis=1, inplace=True)
df_bank.groupby('y')['campaign'].count()

df_bank.groupby('y').agg({'campaign': ['median', 'mean']})