Pandas에서 연속 중복 제거
Pandas의 drop_duplicates() 메소드는 모든 중복 값을 제거하는 데 효과적이지만 연속 발생을 식별하지는 않습니다. . 이러한 제한을 해결하기 위해 연속된 중복 항목만 선택적으로 삭제하는 효율적인 방법이 있습니다.
한 가지 접근 방식은 시프트 기능을 사용하여 현재 값을 이전 값과 비교합니다.
a.loc[a.shift() != a]
이 논리는 다음을 반환합니다. 연속된 중복이 False 값으로 특성화되는 마스크입니다. 그런 다음 loc 방법은 True 값이 있는 행만 선택하여 연속 중복 항목을 효과적으로 제거합니다.
또 다른 방법은 diff 기능을 활용하여 변경 사항을 감지합니다.
a.loc[a.diff() != 0]
그러나 이 접근 방식은 덜 효율적입니다. 미분 계산과 관련된 오버헤드로 인해 대규모 데이터 세트의 경우
업데이트
기본 이동 기간이 1이므로 Shift() 및 Shift( 1) 동일한 결과 생성:
a.loc[a.shift(1) != a]
이렇게 하면 첫 번째 연속 값이 중복 항목으로 올바르게 식별됩니다.
위 내용은 Pandas에서 연속 중복을 제거하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond

pythonisnotpurelynlogreted; itusesahybrideprophorfbyodecodecompilationandruntime -INGRETATION.1) pythoncompilessourcecodeintobytecode, thepythonVirtualMachine (pvm)

ToconcatenatelistsinpythonwithesameElements, 사용 : 1) OperatorTokeEpduplicates, 2) asettoremovedUplicates, or3) listComperensionForControlOverDuplicates, 각 methodHasDifferentPerferformanCeanDorderImpestications.

PythonisancerpretedLanguage, 비판적 요소를 제시하는 PytherfaceLockelimitationsIncriticalApplications.1) 해석 된 언어와 같은 thePeedBackandbackandrapidProtoTyping.2) CompilledlanguagesLikec/C transformt 해석

useforloopswhhenmerfiterationsiskNownInAdvance 및 WhileLoopSweHeniTesslationsDepoyConditionismet whilEroopsSuitsCenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTherInatismet, 유용한 광고 인 푸트 gorit


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

Dreamweaver Mac版
시각적 웹 개발 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!