Skip to content

Instantly share code, notes, and snippets.

@2torus
Created October 5, 2018 06:11
Show Gist options
  • Save 2torus/825a501163e7bbf37af5b235a4a65222 to your computer and use it in GitHub Desktop.
Save 2torus/825a501163e7bbf37af5b235a4a65222 to your computer and use it in GitHub Desktop.
Determine if you won Lightricks datahack competition
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