Last active
July 28, 2017 13:39
-
-
Save zverbatim/86db71ffeb30941e890a68a961d83f2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# filter an array | |
# version 1 | |
areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50] | |
valid = lambda x: type(x) == float | |
sum = sum( filter (valid, areas) ) | |
# version 2 | |
out = [a for a in areas if type(a) != str] | |
# pandas from lists | |
import pandas as pd | |
list_keys = ['Country', 'Total'] | |
list_values = [['US', 'Mexico', 'Canada'], [1000, 500, 400]] | |
zipped = list(zip(list_keys, list_values)) | |
data = dict(zipped) | |
df = pd.(data) | |
print(df.head()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment