Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import random
- df = pd.read_csv('https://vk.com/s/v1/doc/oL105c1nIh_2md8ugsA48yZ12YLEGVJunJAaUXqDPM5bhjK8KLA')
- df['target'] = [random.choice([0,1]) for _ in range(len(df))]
- pivot = df.pivot_table(
- values = ['training_hours'],
- index = ['education_level', 'target'],
- columns = ['gender'],
- aggfunc = 'sum',
- margins = True,
- fill_value = 0,
- )
- display(pivot)
Advertisement
Add Comment
Please, Sign In to add comment