Skip to content

Instantly share code, notes, and snippets.

@finnp
Last active August 29, 2015 14:21
Show Gist options
  • Save finnp/f0362330c9dfb85863e9 to your computer and use it in GitHub Desktop.
Save finnp/f0362330c9dfb85863e9 to your computer and use it in GitHub Desktop.
def force_float(str):
try:
return float(str)
except (ValueError):
return 0.0
def rcp_poll_data(xml):
dom = web.Element(test_xml)
dates = [date.content for date in dom('series value')]
titles = {}
for value in dom('graphs graph value'):
col = value.parent.attributes['title']
if not col in titles: titles[col] = []
titles[col].append(force_float(value.content))
titles['date'] = pd.to_datetime(dates)
return pd.DataFrame(titles).sort('date')
print rcp_poll_data(test_xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment