Last active
August 29, 2015 14:21
-
-
Save finnp/f0362330c9dfb85863e9 to your computer and use it in GitHub Desktop.
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
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