def football_data(season='<STR_LIT>', data_set='<STR_LIT>'):
def league2num(string):<EOL><INDENT>league_dict = {'<STR_LIT>':<NUM_LIT:0>, '<STR_LIT>':<NUM_LIT:1>, '<STR_LIT>': <NUM_LIT:2>, '<STR_LIT>': <NUM_LIT:3>, '<STR_LIT>':<NUM_LIT:4>}<EOL>return league_dict[string]<EOL><DEDENT>def football2num(string):<EOL><INDENT>if string in football_dict:<EOL><INDENT>return football_dict[string]<EOL><DEDENT>else:<EOL><INDENT>football_dict[string] = len(football_dict)+<NUM_LIT:1><EOL>return len(football_dict)+<NUM_LIT:1><EOL><DEDENT><DEDENT>data_set_season = data_set + '<STR_LIT:_>' + season<EOL>data_resources[data_set_season] = copy.deepcopy(data_resources[data_set])<EOL>data_resources[data_set_season]['<STR_LIT>'][<NUM_LIT:0>]+=season + '<STR_LIT:/>'<EOL>start_year = int(season[<NUM_LIT:0>:<NUM_LIT:2>])<EOL>end_year = int(season[<NUM_LIT:2>:<NUM_LIT:4>])<EOL>files = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if start_year><NUM_LIT:4> and start_year < <NUM_LIT>:<EOL><INDENT>files += ['<STR_LIT>']<EOL><DEDENT>data_resources[data_set_season]['<STR_LIT>'] = [files]<EOL>if not data_available(data_set_season):<EOL><INDENT>download_data(data_set_season)<EOL><DEDENT>from matplotlib import pyplot as pb<EOL>for file in reversed(files):<EOL><INDENT>filename = os.path.join(data_path, data_set_season, file)<EOL>writename = os.path.join(data_path, data_set_season, '<STR_LIT>')<EOL>input = open(filename, '<STR_LIT:rb>')<EOL>output = open(writename, '<STR_LIT:wb>')<EOL>writer = csv.writer(output)<EOL>for row in csv.reader(input):<EOL><INDENT>if any(field.strip() for field in row):<EOL><INDENT>writer.writerow(row)<EOL><DEDENT><DEDENT>input.close()<EOL>output.close()<EOL>table = np.loadtxt(writename,skiprows=<NUM_LIT:1>, usecols=(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:5>), converters = {<NUM_LIT:0>: league2num, <NUM_LIT:1>: pb.datestr2num, <NUM_LIT:2>:football2num, <NUM_LIT:3>:football2num}, delimiter='<STR_LIT:U+002C>')<EOL>X = table[:, :<NUM_LIT:4>]<EOL>Y = table[:, <NUM_LIT:4>:]<EOL><DEDENT>return data_details_return({'<STR_LIT:X>': X, '<STR_LIT:Y>': Y}, data_set)<EOL>
Football data from English games since 1993. This downloads data from football-data.co.uk for the given season.