데이터 클렌징(Data Cleansing)이란?

전처리(preprossessing) 과정의 하나로, 자료에서 불완전하거나, 비정확하거나, 관련 없는 부분을 찾아 삭제하거나 수정하는 것을 말합니다. 테이블에 빈 칸이 있거나, 단위가 잘못되었거나, 오타가 있거나 등등의 경우에 원하는 결과를 얻을 수 없기 때문에 분석하기 전에 미리 처리를 해주는 것이죠. 우리의 경우에는 내보내기한 카카오톡을 열어보면 날짜, 시간, 프로필 이름 등의 무의미한 부분이 반복적으로 나타나기 때문에 이것들을 지워주어야 더 흥미로운, 실제로 사람들이 사용한 단어를 강조할
수 있습니다.

from wordcloud import WordCloud
text = ""

with open("kakaotalk.txt", "r", encoding="utf-8") as file:
lines = file.readlines()
for line in lines:
if '] [' in line:
text += line.split('] ')[2].replace('ㅋ','').replace('ㅠ','').replace('ㅜ','').replace('사진\n','').replac
font_path = 'C:/Windows/Fonts/CoreGTM3.otf'
wc = WordCloud(font_path=font_path, background_color="white", width=600, height=400)
wc.generate(text)
wc.to_file("result.png")
profile
Next generation Data Scientist

0개의 댓글