-
[pandas], 콤마 제외하고 특수 문자 제거 ( 데이터프레임, replace, 정규표현식)데이터분석 2022. 11. 11. 12:51
정규 표현식 이용하면 됨
^ : not 제외한다
\u : 유니코드
AC00 - D7A3 : 유니코드 한글
0-9 : 숫자
a-zA-z: 영어 (대소문자)
\s : 공백 (Space,Tab)
한글, 영어, 숫자, 콤마 이외 표현은 아래와 같음 .
[^,\uAC00-\uD7A30-9a-zA-Z\s]sample['keyword'].str.replace(r'[^,\uAC00-\uD7A30-9a-zA-Z\s]', '', regex=True)
한글,영어,숫자, 콤마 (,) , 닷 (.) 이외의 특수문자를 제거하고 싶으면 아래와 같이
[^.,\uAC00-\uD7A30-9a-zA-Z\s]
How to remove all special character in a string except dot and comma
I have a sentence with many special characters and text in it, I want remove all the special characters except dot and comma. For example, this is what have: [u' %$HI# Jhon, $how$ are *&$%y...
stackoverflow.com
'데이터분석' 카테고리의 다른 글
특정 연도 이전,이후 인덱스 찾는 방법 (0) 2023.03.14 [pandas] 아이디 기준으로 최근 거래 항목 3개 뽑고 싶을 때 groupby ,tail (0) 2022.11.25 [pandas]데이터프레임 행 단위 연산 (apply, 조건에 맞게 처리,예외 처리) (0) 2022.11.10 [pandas] read_csv 화폐 단위 열 콤마(,) 제외하고 숫자로 읽어오기 (0) 2022.10.14 [pandas] read_csv 필요한 열만 읽기 usecols (0) 2022.10.13