Skip to content

Instantly share code, notes, and snippets.

df.columns = df.iloc[0]
df = df.iloc[1:-1, :-1]
sf_data = df
sf_data.head()
response = requests.get("http://www.healthysf.org/bdi/outcomes/zipmap.htm")
soup = BeautifulSoup(response.text, "lxml")
table = soup.find_all("table")
df = pd.read_html(str(table))
df = pd.DataFrame(df[4])
import requests # library to handle requests
from bs4 import BeautifulSoup
import pandas as pd
names = [name for name in names if len(name) > 1]
import random
def grey_color_func(word, font_size, position, orientation, random_state=None,
**kwargs):
return "hsl(0, 0%%, %d%%)" % random.randint(60, 100)
plt.figure(figsize=(15,8))
plt.imshow(wordcloud.recolor(color_func=grey_color_func, random_state=3), interpolation='bilinear')
plt.axis("off")
unique_string=(" ").join(names)
wordcloud = WordCloud(width = 1000, height = 500).generate(unique_string)
plt.figure(figsize=(15,8))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()
pip install wordcloud
import numpy as np
from os import path
from PIL import Image
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
import matplotlib.pyplot as plt
% matplotlib inline
from nltk.probability import FreqDist
fdist = FreqDist(names).most_common(20)
names = [name for name in names if name not in a]
from nltk import word_tokenize
import nltk
nltk.download('stopwords')
from nltk.corpus import stopwords
a = set(stopwords.words('english'))