Exemple #1
0
import health
import matplotlib.pyplot as plt
from textblob import TextBlob

from wordcloud import WordCloud

diseaseSearch = 'disease'

list_of_report = health.get_all_reports()

combinedDiseases = ''

for dis in list_of_report:
    combinedDiseases += ' ' + dis['disease']

healthBlob = TextBlob(combinedDiseases)

diseaseDictionary = dict()

for word in healthBlob.words:
    diseaseDictionary[word.lower()] = healthBlob.word_counts[word.lower()]

wordCloud = WordCloud(
    background_color='white').generate_from_frequencies(diseaseDictionary)
plt.title('Diseases in the US')
plt.axis('off')

for dis in list_of_report:
    healthBlob = TextBlob(dis['disease'])

plt.imshow(wordCloud, interpolation='bilinear')
from course import corgis

import health
data = health.get_all_reports()
data = corgis.data2frame(data)
data.to_csv('health.csv',index=False)
Exemple #3
0
    return state_index_values


def state_list(reports, year):
    states = []
    for report in reports:  # makes a list of all states
        if report["year"] == year:
            if report["loc"] not in states:
                states.append(report["loc"])
                #print(report["loc"], " pop =", report["population"])
    return states


#------------------------------------------------------------------------------

reports = health.get_all_reports()

states = state_list(reports, 2000)

population2000 = annual_pop(reports, 2000)

most_populated2000 = most_populated(population2000)

pop_state_index2000 = find_pop_index_values(most_populated2000, population2000)

most_populated_states2000 = find_states(pop_state_index2000, states)

number_sick2000 = number_sick(reports, 2000)
most_sick2000 = most_sick(number_sick2000)
sick_state_index2000 = find_sick_index_values(most_sick2000, number_sick2000)
most_sick_states2000 = find_states(sick_state_index2000, states)