Exemplo n.º 1
0
import billionaires
list_of_billionaires = billionaires.get_billionaires()

print(list_of_billionaire[0])  #HOW TO GET FIRST ITEM IN LIST
print(list_of_billionaire)

for i in range(len(list_of_billionaires)):
    b = list_of_billionaires
    print(b[i]['name'], b[i]['location']['country code'])

# BOTH SAME THING ^

for i in list_of_billionaires:
    print(i['name'], i['location']['country code'])

for i in list_of_billionaires:
    print(i['name'], i['demographics']['age'], i['demographics']['gender'],
          i['wealth']['worth in billions'])

# SAME THING ^

ages = []

for demo in list_of_billionaires:
    name = demo['name']
    age = demo['demographics']['age']
    gender = demo['demographics']['gender']
    worth = demo['wealth']['worth in billions']
    print(name, age, gender, worth)
    ages.append(age)
print(ages)
Exemplo n.º 2
0
import billionaires
from textblob import TextBlob
import matplotlib.pyplot as plt
import numpy as np
#from wordcloud import WordCloud
list_of_richies = billionaires.get_billionaires()

locationstring = ""
countlocal= {}
usedlist = []
percentcountry = {}
all_countries = []

for row in list_of_richies:
    onelist =row["location"]["country code"]
    locationstring += onelist + ","

lb = TextBlob(locationstring)
locationlist = lb.words
for code in locationlist:
    if code in usedlist:
        countlocal[code] += 1
    else:
        countlocal[code] = 1
        usedlist.append(code)
#print(countlocal)

total = len(locationlist)

for location in locationlist:
    if location in all_countries: