Work in Progress
# read population in
import json
import requests
from pandas import DataFrame
# pop_json_url holds a
pop_json_url = "https://gist.github.com/rdhyee/8511607/raw/f16257434352916574473e63612fcea55a0c1b1c/population_of_countries.json"
pop_list= requests.get(pop_json_url).json()
df = DataFrame(pop_list)
df[:5]
0 | 1 | 2 | |
---|---|---|---|
0 | 1 | China | 1385566537 |
1 | 2 | India | 1252139596 |
2 | 3 | United States | 320050716 |
3 | 4 | Indonesia | 249865631 |
4 | 5 | Brazil | 200361925 |
5 rows × 3 columns
Q: What is the relationship between s
and the population of China?
s = sum(df[df[1].str.startswith('C')][2])
s
is greater than the population of Chinas
is the same as the population of Chinas
is less than the population of Chinas
is not a number.from pandas import DataFrame, Series, Index
import numpy as np
s1 = Series(np.arange(1,4))
s1
0 1 1 2 2 3 dtype: int64
Q: What is
s1.apply(lambda k: 2*k).sum()
Q: What is s1.cumsum()[1]
?