pandas 에서 DataFrame 에서 중복 값 의 실현 을 감지 합 니 다.
DataFrame.duplicated(subset=None, keep='first')
subset:몇 필드 가 중복 된다 고 생각 되면 데이터 가 중복 되 며,그 필드 를 목록 으로 subset 뒤에 놓 으 십시오.기본 값 은 모든 필드 가 중복 데이터 로 반 복 됩 니 다.keep:
df = pd.DataFrame({
'brand': ['Yum Yum', 'Yum Yum', 'Indomie', 'Indomie', 'Indomie'],
'style': ['cup', 'cup', 'cup', 'pack', 'pack'],
'rating': [4, 4, 3.5, 15, 5]
})
df
# keep="first", False, True
# keep, keep 。
df.duplicated()
0 False
1 True
2 False
3 False
4 False
dtype: bool
# keep="last",, False, True
df.duplicated(keep="last")
0 True
1 False
2 False
3 False
4 False
dtype: bool
# keep=False,, True
df.duplicated(keep=False)
0 True
1 True
2 False
3 False
4 False
dtype: bool
# sub ,subset
# brand 。
df.duplicated(subset='brand')
0 False
1 True
2 False
3 True
4 True
dtype: bool
# brand brand style 。
df.duplicated(subset=['brand','style'])
0 False
1 True
2 False
3 False
4 True
dtype: bool
# ,
df[df.duplicated()]
# 。
df.duplicated().sum()
1
pandas 에서 DataFrame 에서 중복 값 을 검출 하 는 실현 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 관련 pandas DataFrame 에서 중복 값 을 검출 하 는 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 조회 하 시기 바 랍 니 다.앞으로 많은 응원 바 랍 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【Pandas】DatetimeIndex란? no.29안녕하세요, 마유미입니다. Pandas에 대한 기사를 시리즈로 작성하고 있습니다. 이번은 제29회의 기사가 됩니다. 에서 Pandas의 시간에 대한 모듈에 대해 씁니다. 이번 기사에서는, 「DatetimeIndex」...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.