본문 바로가기
DataScience/Python

데이터프레임에 "특정단어"가 들어가있는지 여부 pd.str.contains()

by leopard4 2022. 11. 29.

데이터 중 choice_description 값에 Vegetables 들어가지 않는 경우의 갯수를 출력하라

df.loc[ df["choice_description"].str.contains("Vegetables", case =False) == False, ]

 

혹은, 

df.loc[ ~df["choice_description"].str.contains("Vegetables",case =False), ]

# case = False = 대문자 , 소문자 상관없이 가져와라