Skip to content

Instantly share code, notes, and snippets.

@allanaguilar
Last active February 25, 2019 19:15
Show Gist options
  • Save allanaguilar/646ccc1e40c3570ae6357c526a8d4eef to your computer and use it in GitHub Desktop.
Save allanaguilar/646ccc1e40c3570ae6357c526a8d4eef to your computer and use it in GitHub Desktop.
# CONVERT ANY STRING TO FLOAT
def string_to_float(v):
if isinstance(v, (int, float)):
res = v
else:
v2 = v.replace(",","")
res = float(v2) if v2.replace(".","").isdigit() else 0
return res
# SHORT LOOP FOR
[doc["doc"] for doc in rows if 'views' not in doc["doc"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment