본문 바로가기

[NLP/Python] 정규표현식 (re) . 임의의 문자 1개 (\n 제외) a? a가 최소 0개 최대 1개 존재 a* a가 최소 0개 이상 존재 a+ a가 최소 1개 이상 존재 ^a a로 문자열 시작 a$ a로 문자열 종료 ex1) 단어 사이 띄어쓰기 상관 없이 찾아서 대체하기 import re sentence = re.sub('불편.?사항', '불편', sentence) ex2) 여러 단어 한꺼번에 find할 때 import re for word in re.finditer('없음|없다|없고', sentence): print(word.start(), word.end())
[Python] pandas_profiling : EDA를 더 쉽게 해보자! https://wikidocs.net/book/2155를 통해 NLP 공부를 하다가 발견하게 된 pandas_profiling 함수. 보자마자 이런 함수가 있다는걸 진작에 알았더라면 싶었다. (하지만 설치하는 과정은..... 음..... 🙄) 설치 설치가 프롬프트 창에서 pip로는 불러와지지 않았다. 그래서 해결한 방법! import sys !{sys.executable} -m pip install pandas-profiling 결과 (데이터는 한창 준비하고 있는 Kaggle의 Real or Not? NLP with Disaster Tweet 대회 데이터를 이용했다.) dataTrain = pd.read_csv('train.csv') pandas_profiling.ProfileReport(dataTrai..
[Python] kaggle bike 데이터를 이용한 pandas 전처리 / seaborn 시각화 trn : train data / tes : test data >> datetime 전처리 # datetime 열에서 시간, 요일, 월, 연도 열 추출 trn['hour'] = [t.hour for t in pd.DatetimeIndex(trn.datetime)] trn['month'] = [t.month for t in pd.DatetimeIndex(trn.datetime)] trn['year'] = [t.year for t in pd.DatetimeIndex(trn.datetime)] tes['hour'] = [t.hour for t in pd.DatetimeIndex(tes.datetime)] tes['month'] = [t.month for t in pd.DatetimeIndex(tes.datet..