Last active
August 21, 2017 06:24
-
-
Save AntoineToubhans/f212348410e3d0bebc690dba26fe33d3 to your computer and use it in GitHub Desktop.
This file contains 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
def _log(message): | |
print('[SimpleTimeTracker] {function_name} {total_time:.3f}'.format(**message)) | |
@simple_time_tracker(_log) | |
def load(): | |
df = pd.read_csv('/home/toubi/Works/sicara/h3/HyperCube/App/Demo/Demo/Titanic.csv', delimiter=';') | |
return df | |
@simple_time_tracker(_log) | |
def compute_max_ticket_price_per_class(df): | |
return { cl: df[cl == df.Class]['Ticket price'].max() for cl in range(1, 4) } | |
@simple_time_tracker(_log) | |
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]) | |
@simple_time_tracker(_log) | |
def run(): | |
df = load() | |
normalize_ticket_price_per_class(df) | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment