데이터분석

[pandas], 콤마 제외하고 특수 문자 제거 ( 데이터프레임, replace, 정규표현식)

jadePark 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

 

https://stackoverflow.com/questions/39672094/how-to-remove-all-special-character-in-a-string-except-dot-and-comma

 

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