import pandas as pd
kills_df = pd.read_json("https://www.uchicagohvz.org/game/1/data/kills/")
kills_df.to_csv("./zombies_kills.csv")
df = pd.read_csv("./zombies_kills.csv", index_col=1, parse_dates=True)
--------------------------------------------------------------------------- HTTPError Traceback (most recent call last) <ipython-input-1-c788cee8bfc6> in <module>() 1 import pandas as pd 2 ----> 3 kills_df = pd.read_json("https://www.uchicagohvz.org/game/1/data/kills/") 4 kills_df.to_csv("./zombies_kills.csv") 5 df = pd.read_csv("./zombies_kills.csv", index_col=1, parse_dates=True) /Users/hunterowens/anaconda3/lib/python3.5/site-packages/pandas/io/json.py in read_json(path_or_buf, orient, typ, dtype, convert_axes, convert_dates, keep_default_dates, numpy, precise_float, date_unit) 184 """ 185 --> 186 filepath_or_buffer, _, _ = get_filepath_or_buffer(path_or_buf) 187 if isinstance(filepath_or_buffer, compat.string_types): 188 try: /Users/hunterowens/anaconda3/lib/python3.5/site-packages/pandas/io/common.py in get_filepath_or_buffer(filepath_or_buffer, encoding, compression) 219 220 if _is_url(filepath_or_buffer): --> 221 req = _urlopen(str(filepath_or_buffer)) 222 if compression == 'infer': 223 content_encoding = req.headers.get('Content-Encoding', None) /Users/hunterowens/anaconda3/lib/python3.5/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 160 else: 161 opener = _opener --> 162 return opener.open(url, data, timeout) 163 164 def install_opener(opener): /Users/hunterowens/anaconda3/lib/python3.5/urllib/request.py in open(self, fullurl, data, timeout) 469 for processor in self.process_response.get(protocol, []): 470 meth = getattr(processor, meth_name) --> 471 response = meth(req, response) 472 473 return response /Users/hunterowens/anaconda3/lib/python3.5/urllib/request.py in http_response(self, request, response) 579 if not (200 <= code < 300): 580 response = self.parent.error( --> 581 'http', request, response, code, msg, hdrs) 582 583 return response /Users/hunterowens/anaconda3/lib/python3.5/urllib/request.py in error(self, proto, *args) 507 if http_err: 508 args = (dict, 'default', 'http_error_default') + orig_args --> 509 return self._call_chain(*args) 510 511 # XXX probably also want an abstract factory that knows when it makes /Users/hunterowens/anaconda3/lib/python3.5/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args) 441 for handler in handlers: 442 func = getattr(handler, meth_name) --> 443 result = func(*args) 444 if result is not None: 445 return result /Users/hunterowens/anaconda3/lib/python3.5/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs) 587 class HTTPDefaultErrorHandler(BaseHandler): 588 def http_error_default(self, req, fp, code, msg, hdrs): --> 589 raise HTTPError(req.full_url, code, msg, hdrs, fp) 590 591 class HTTPRedirectHandler(BaseHandler): HTTPError: HTTP Error 403: Forbidden
df.head(5)
Unnamed: 0 | id | killer | location | points | victim | |
---|---|---|---|---|---|---|
date | ||||||
2013-10-15 23:47:30.818000 | 0 | 239 | Shenyang Mao | [41.7896488842118, -87.5997018814087] | 1 | Rahul Sinha |
2013-10-15 23:43:24.595000 | 1 | 238 | Michael Procassini | [41.7894888963805, -87.5999540090561] | 1 | Mary Barclay |
2013-10-15 23:34:04.067000 | 2 | 237 | Wesley Jones | [41.7894009029031, -87.5992459058762] | 1 | Stanley Breitweiser |
2013-10-15 23:32:53.405000 | 3 | 236 | Seth Arar | [41.7896888811073, -87.5992941856384] | 1 | Wesley Jones |
2013-10-15 23:22:55.788000 | 4 | 235 | Seth Arar | [41.7893049098809, -87.5993478298187] | 1 | Yida Cai |
5 rows × 6 columns
df2 = df[df.index!=pd.NaT]
df2['n'] = 1
df2.n.resample('H', how="sum")
plot(df2.n.resample('H', how="sum"))
[<matplotlib.lines.Line2D at 0x106fe9ad0>]