728x90
DataFrame은 다음과 같다
요구사항 : df의 데이터 중 choice_description 값에 Vegetables 들어가지 않는 경우의 갯수를 출력하라
df['choice_description'].str.contains('Vegetables',case=False) ## 먼저 포함되는 것을 찾는다.
(df['choice_description'].str.contains('Vegetables',case=False) == False).sum() ## ~을 알기 전에 내가 사용했던 코드,
~df['choice_description'].str.contains('Vegetables',case=False) ## 이것보다 간단한 방법이 있는 것을 알게된 후 ~을 사용한 코드
~을 사용하니 True와 False가 서로 바뀐 결과는 위 사진과 같습니다.
'Python' 카테고리의 다른 글
Python파이썬 pandas 데이터 시각화 plot() (0) | 2022.11.29 |
---|---|
Python파이썬 pandas 데이터프레임으로 만들기 to_frame() (0) | 2022.11.29 |
Python파이썬 데이터 시각화 matplotlib heatmaps hist2d() (0) | 2022.11.28 |
Python파이썬 데이터 시각화 matplotlib seaborn regplot , pairplot (0) | 2022.11.28 |
Python파이썬 데이터 시각화 matplotlib scatterplots, (0) | 2022.11.28 |