Created
October 5, 2018 06:11
-
-
Save 2torus/825a501163e7bbf37af5b235a4a65222 to your computer and use it in GitHub Desktop.
Determine if you won Lightricks datahack competition
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
import numpy as np | |
import pandas as pd | |
import requests | |
def didWeWin(team_name): | |
text = requests\ | |
.get('https://raw.githubusercontent.com/Lightricks/datahack/master/leaderboard.md')\ | |
.text\ | |
.split("\n") | |
def get_line(line): | |
return list(map(lambda x:x.strip(), line.split("|"))) | |
raw_data = text[2:] | |
raw_data = list(map(get_line, raw_data)) | |
headers = get_line(text[0]) | |
headers[0] = 'index' | |
headers[1] = 'index0' | |
headers[2] = 'date' | |
data = pd.DataFrame(data=raw_data, columns=headers).drop(['index0',''], axis=1) | |
for column in data.columns[5:]: | |
data[column] = data[column].astype(np.float_) | |
data = data.set_index("Team name") | |
leaderboard = data.groupby(lambda name:name.lower())['F1 score']\ | |
.max()\ | |
.sort_values(ascending=False)\ | |
.reset_index()\ | |
.rename(columns = {"index":"team"}) | |
#return leaderboard.loc[0, 'team']==team_name.lower() | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment