문자열처리
email=email.str.strip()
a.strip('*')
>>'abcd'
def clean_text(inputString):
text_rmv = re.sub('[-=+,#/\?:^.@*\"※~ㆍ!』‘|\(\)\[\]`\'…》\”\“\’·]', '', inputString)
return text_rmv
df['refined']=df['refined'].apply(clean_text)
email.str.pad(width=20, fillchar='_')
email.str.pad(width=20, fillchar='*', side='right')
email=email.str.replace(' at', '@')
Sereis.str.replace('hankook|hanguk|hankuk|hangug', '')
Sereis.str.translate(str.maketrans('123','456')
email.str.lower()
email.str.upper()
여러 개의 문자(character) 변환하기
email.str.split('@')
email.str.split('@', expand=True)
email.str.split('.', n=1, expand=True)
email.str.rsplit('.', n=1, expand=True)
확인메서드
email.str.len()
email.str.count('a')
email.str.find('@')
email.str.rfind('.')
email.str.startswith('h')
email[email.str.startswith('h')]
email.str.endswith('r')
email.str.contains('co.')
email.str.contains('co\.')
email.str.str.replace(r'\(주\)','')
str.isdigit()
str.isdigit("판단하고자 하는 문자열")
문자열 dataframe
tag_group = tags.groupby('id')[['value']].agg(lambda x: ', '.join(x)).reset_index()
df = cmd_difid['other_id'].str.split(',', expand=True)
df = other_id.stack().reset_index(level=1, drop=True).to_frame('id_2')
flat_card= data.merge(df, left_index=True, right_index=True, how='left')
flat_card
기타
print(f'{c}개 주성분 :{v:.4f}')