오름차순인지 확인 tmp안의 요소가
all([col[i] <= col[i+1] for col in tmp for i in range(len(col)-1)])
소문자, 엔터 → 스페이스바, a-z0-9가 아닌 텍스트 제거
for idx, text in enumerate(df['text']):
text = text.lower()
text = text.replace('\\n',' ')
text = re.sub(r'[^a-z0-9 ]', '', text)
df['description'][idx] = text
swapcase : 소문자, 대문자 전환
str = "this is string example....wow!!!"
print(str.swapcase())
isalpha : 영어인지 확인
'a'.isalpha()
isdigit : 숫자 인지 확인
# Appia Example for isalpha
# It is to explain how to check whether the string consist of digit or not.
Ex1 = '010-1234-5678'
Ex2 = '123456'
Ex3 = "R4R3"
Ex4 = '1.1'
Ex5 = '-1'
print(Ex1.isdigit())
print(Ex2.isdigit())
print(Ex3.isdigit())
print(Ex4.isdigit())
print(Ex5.isdigit())
# False
# True
# False
# False
# False
정수인지 판별
if int(x) == x and int(y) == y:
return int(x), int(y)
isdecimal : 양의 정수인지 판별
'1900'.isdecimal() # True
'0.19'.isdecimal() # False
'-100'.isdecimal() # False
isnumeric : 수로 볼 수 있는 경우 (제곱근, 분수 등)
'\\u0030'.isnumeric() # True, unicode for 0
'\\u00B2'.isnumeric() # True, unicode for ^2
'1km'.isnumeric() # False
'-12'.isnumeric() # False
'1.8'.isnumeric() # False
isalnum : 알파벳 또는 숫자인지 확인
# Appia Example for isalpha
# It is to explain how to check whether the string consist of digit/alphabet or not.
Ex1 = '안녕'
Ex2 = 'Hello3'
Ex3 = "1.Where"
Ex4 = "1 Where"
print(Ex1.isalnum())
print(Ex2.isalnum())
print(Ex3.isalnum())
print(Ex4.isalnum())
# True
# True
# False
# False
isupper : 대문자 인지 확인
islower : 소문자 인지 확인