Word cloud document
https://amueller.github.io/word_cloud/index.html
from wordcloud import WordCloud
import pandas as pd
import folium
import seaborn as sns
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
survey_raw_df = pd.read_csv('C:/Chang_git/Data/survey_results_public.csv',index_col = 'ResponseId')
temp_words = survey_raw_df['DevType'].dropna() # NaN값을 모두 버리는 과정
temp_words = temp_words.str.replace(';',' ').str.replace(',',' ') # 중복 선택을 하나씩 나누는 과정
words = ' '.join(temp_words) # 공백 구분자를 통해 단 하나의 문자열로 합치는 명령어
#words
wc = WordCloud(collocation_threshold = int(1e6),
width=800, height = 400,
background_color = 'lightgrey'
).generate(words)
plt.figure(figsize = (16,8))
plt.axis('off')# x,y축을 그리지 않는다.
#grid lines를 그리지 않는다
plt.grid(False)
plt.imshow(wc)
wc.to_file('DevType.png') # 로 저장할 수 있다.
plt.show()

'파이썬 > 파이썬 시각화' 카테고리의 다른 글
7. Folium (0) | 2023.05.02 |
---|---|
6. Seaborn - 3 (0) | 2023.05.02 |
5. Seaborn - 2 (0) | 2023.05.02 |
4. Seaborn - 1 (0) | 2023.05.02 |
3. Matplotlib - 3 (0) | 2023.05.02 |
Word cloud document
https://amueller.github.io/word_cloud/index.html
from wordcloud import WordCloud
import pandas as pd
import folium
import seaborn as sns
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
survey_raw_df = pd.read_csv('C:/Chang_git/Data/survey_results_public.csv',index_col = 'ResponseId')
temp_words = survey_raw_df['DevType'].dropna() # NaN값을 모두 버리는 과정
temp_words = temp_words.str.replace(';',' ').str.replace(',',' ') # 중복 선택을 하나씩 나누는 과정
words = ' '.join(temp_words) # 공백 구분자를 통해 단 하나의 문자열로 합치는 명령어
#words
wc = WordCloud(collocation_threshold = int(1e6),
width=800, height = 400,
background_color = 'lightgrey'
).generate(words)
plt.figure(figsize = (16,8))
plt.axis('off')# x,y축을 그리지 않는다.
#grid lines를 그리지 않는다
plt.grid(False)
plt.imshow(wc)
wc.to_file('DevType.png') # 로 저장할 수 있다.
plt.show()

'파이썬 > 파이썬 시각화' 카테고리의 다른 글
7. Folium (0) | 2023.05.02 |
---|---|
6. Seaborn - 3 (0) | 2023.05.02 |
5. Seaborn - 2 (0) | 2023.05.02 |
4. Seaborn - 1 (0) | 2023.05.02 |
3. Matplotlib - 3 (0) | 2023.05.02 |