Last active
August 18, 2017 17:00
-
-
Save AntoineToubhans/4b0865a593b0565dcbb466274c3e07c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| def load(): | |
| df = pd.read_csv('/home/toubi/Titanic.csv', delimiter=';') | |
| return df | |
| def compute_max_ticket_price_per_class(df): | |
| return { cl: df[cl == df.Class]['Ticket price'].max() for cl in range(1, 4) } | |
| def normalize_ticket_price_per_class(df): | |
| max_per_class = compute_max_ticket_price_per_class(df) | |
| df['normalized_ticket_price'] = df['Ticket price'] / df.Class.apply(lambda cl: max_per_class[cl]) | |
| def run(): | |
| df = load() | |
| normalize_ticket_price_per_class(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment