8
명확한 예를 제공하기 위해 제 질문을 업데이트했습니다.Pandas drop_duplicates - TypeError : 유형 객체 인수 뒤에 *는 시퀀스가 아니어야합니다.
값이 목록을 포함하는 열 ID를 기반으로 중복 행을 제거하려면 Pandas에서 drop_duplicates 메서드를 사용할 수 있습니까? 목록에서 두 항목으로 구성된 열 '3'을 고려하십시오. 중복 행을 반복적으로 수행하는 것보다 삭제하는 방법이 있습니까 (이것이 현재 해결 방법입니다). 다음과 같은 오류에
import pandas as pd
data = [
{'one': 50, 'two': '5:00', 'three': 'february'},
{'one': 25, 'two': '6:00', 'three': ['february', 'january']},
{'one': 25, 'two': '6:00', 'three': ['february', 'january']},
{'one': 25, 'two': '6:00', 'three': ['february', 'january']},
{'one': 90, 'two': '9:00', 'three': 'january'}
]
df = pd.DataFrame(data)
print(df)
one three two
0 50 february 5:00
1 25 [february, january] 6:00
2 25 [february, january] 6:00
3 25 [february, january] 6:00
4 90 january 9:00
df.drop_duplicates(['three'])
결과 :
TypeError: type object argument after * must be a sequence, not map
을'df_two = df_one.drop_duplicates ('ID') '또는 특히'df_two = df_one.drop_duplicates (집합 = ['ID '])' – EdChum
두려운 것은 그 문제를 해결하지 못했다. 여전히 동일한 오류가 발생합니다. – user3939059
'df_two = df_one.drop_duplicates()'가 작동합니까? – EdChum