드레:
코딩 뿌시기
드레:
전체 방문자
오늘
어제
  • 분류 전체보기 (268)
    • Python (74)
      • Python 기초 (42)
      • Numpy (8)
      • Pandas (22)
    • Machine Learning (31)
      • Machine Learning (1)
      • Deep Learning (27)
    • AWS (22)
      • RDS (3)
      • EC2 (9)
      • Lambda (8)
      • S3 (2)
    • MySQL (24)
    • Git (8)
    • Streamlit (12)
    • REST API (22)
    • Java (24)
    • Android (36)
    • Debugging (15)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • Lambda
  • Transfer Learning
  • 깃이그노어
  • JWT
  • Ann
  • Callback
  • 네이버 API
  • API
  • rest api
  • EC2
  • aws s3
  • github
  • Streamlit
  • 액션바
  • 서버리스
  • fine tuning
  • volley
  • pandas
  • 안드로이드 스튜디오
  • AWS
  • AWS Lambda
  • Python
  • Java
  • Retrofit2
  • serverless
  • 딥러닝
  • flask
  • CNN
  • tensorflow
  • GET

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
드레:

코딩 뿌시기

Python 비트연산자 ~ 의 활용
Python/Pandas

Python 비트연산자 ~ 의 활용

2022. 11. 29. 12:25

df

'df의 데이터 중 choice_description 값에 Vegetables 들어가지 않는 데이터를 출력하라'

는 문제를 풀기 위해 ~를 사용해봤다.

~ 는 비트연산자로 not을 의미하고 True, False의 결과를 뒤집는다.

# Vegetables를 포함하는 경우
df['choice_description'].str.contains('Vegetables', case=False)
>>> 0       False
    1       False
    2       False
    3       False
    4       False
            ...  
    4617    False
    4618    False
    4619     True
    4620     True
    4621     True
    Name: choice_description, Length: 4622, dtype: bool
    
# Vegetables를 포함하지 않는 경우
~df['choice_description'].str.contains('Vegetables', case=False)
>>> 0        True
    1        True
    2        True
    3        True
    4        True
            ...  
    4617     True
    4618     True
    4619    False
    4620    False
    4621    False
    Name: choice_description, Length: 4622, dtype: bool
df2 = df.loc[~df['choice_description'].str.contains('Vegetables', case=False), ]
df2

'Python > Pandas' 카테고리의 다른 글

matplotlib, seaborn 을 활용한 데이터 시각화(2) - hist, subplot  (0) 2022.11.30
matplotlib, seaborn 을 활용한 데이터 시각화(1) - plot, countplot, pie  (0) 2022.11.29
Pandas 활용(10) - 데이터프레임 합치기(concat, merge)  (0) 2022.11.28
Pandas 활용(9) - 데이터프레임 정렬하기 sort_values, sort_index  (0) 2022.11.28
Pandas 활용(8) - str 관련 메소드  (0) 2022.11.28
    'Python/Pandas' 카테고리의 다른 글
    • matplotlib, seaborn 을 활용한 데이터 시각화(2) - hist, subplot
    • matplotlib, seaborn 을 활용한 데이터 시각화(1) - plot, countplot, pie
    • Pandas 활용(10) - 데이터프레임 합치기(concat, merge)
    • Pandas 활용(9) - 데이터프레임 정렬하기 sort_values, sort_index
    드레:
    드레:

    티스토리툴바