K-Digital可視化
import pandas as pd
df = pd.read_csv('K-digital.csv')
namelocal
title
period
0
コデスタッツ株式会社
ソウル瑞草区
クラウドサービスの操作と開発!DevOps起動キャンプ
2022年04月15日から2022年08月19日(第2回)
1
大韓商工会議所忠南人力開発院
忠南プリンセス
製造イノベーションインテリジェント工場統合制御設計実践
2022年04月19日から2022年11月29日(第2回)
1.WordCloud(地域)
# 워드클라우드 IMPORT
from konlpy.tag import Okt # 형태소분석기 : Openkoreatext
from collections import Counter # 빈도 수 세기
from wordcloud import WordCloud, STOPWORDS # wordcloud 만들기
import matplotlib.pyplot as plt # 시각화
local = df['local']
local.to_csv('word.txt', encoding='utf-8-sig')
text = open('word.txt', encoding='utf-8-sig').read()
# 형태소 분석기를 통해 명사만 추출하는 함수
def token_konlpy(text):
okt=Okt()
return [word for word in okt.nouns(text) if len(word)>1] # 1글자 명사는 제외
noun = token_konlpy(text)
len(noun)
noun_set = set(noun) # 중복값 제거
# stopwords 변수 만들어서, 차집합으로 빼기
len(noun_set)
# 텍스트 파일로 저장
f = open('noun_set.txt','w', encoding='utf-8')
f.write(str(noun_set))
f.close()
count = Counter(noun)
count.pop('서울') # 계속 중복되는 서울 제외
# 빈도수 상위 15개 까지 딕셔너리 형태로 자료 변환 {'noun':'key'}
word = dict(count.most_common(20))
#wordcloud 만들기
wc = WordCloud(max_font_size=200, font_path = 'C:\Windows\Fonts\malgun.ttf',background_color="white",width=2000, height=500).generate_from_frequencies(word) # font 경로 개별적으로 설정해야함
plt.figure(figsize = (40,40))
plt.imshow(wc)
plt.tight_layout(pad=0)
plt.axis('off')
plt.show()
word
{'서초구': 15,
'동구': 10,
'대구': 9,
'강남구': 9,
'경기': 8,
'종로구': 8,
'광주': 6,
'인천': 6,
'중구': 5,
'부산': 4,
'관악구': 4,
'금천구': 4,
'성남시': 4,
'중원구': 4,
'미추홀': 4,
'부산진구': 3,
'서대문구': 3,
'구로구': 3,
'서구': 3,
'충남': 2}
3.区域棒グラフimport matplotlib as mpl
# bar 차트 그리기
def showGraph(wordInfo):
# font_location = 'C:\Windows\Fonts\HANDotumB.ttf' # font 경로 설정
# font_name = font_manager.FontProperties(fname=font_location).get_name()
plt.xlabel('주요 단어',fontsize=70)
plt.ylabel('빈도수', fontsize=70)
plt.grid(True)
Sorted_Dict_Values = sorted(wordInfo.values(), reverse=True)
Sorted_Dict_Keys = sorted(wordInfo, key=wordInfo.get, reverse=True)
plt.bar(range(len(wordInfo)), Sorted_Dict_Values, align='center')
plt.xticks(range(len(wordInfo)), list(Sorted_Dict_Keys), rotation='70')
plt.rcParams["figure.figsize"] = (50,30)
mpl.rcParams["font.size"] = 50
plt.show()
word2= dict(count.most_common(20)) # 빈도 수 상위 20개로 word2 생성
showGraph(word2)
Reference
この問題について(K-Digital可視化), 我々は、より多くの情報をここで見つけました https://velog.io/@wltn39/K-digital-시각화テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol