我有一个大约有五十万行的数据帧。正如我所看到的,有很多重复的行,所以如何删除所有列(大约80列)中具有相同值的重复行,而不只是一行?
df:
period_start_time id val1 val2 val3
06.13.2017 22:00:00 i53 32 2 10
06.13.2017 22:00:00 i32 32 2 10
06.13.2017 22:00:00 i32 4 2 8
06.13.2017 22:00:00 i32 4 2 8
06.13.2017 22:00:00 i32 4 2 8
06.13.2017 22:00:00 i20 7 7 22
06.13.2017 22:00:00 i20 7 7 22
期望的输出:
period_start_time id val1 val2 val3
06.13.2017 22:00:00 i53 32 2 10
06.13.2017 22:00:00 i32 32 2 10
06.13.2017 22:00:00 i32 4 2 8
06.13.2017 22:00:00 i20 7 7 22
答案 0 :(得分:4)
df = df.drop_duplicates()
print (df)
period_start_time id val1 val2 val3
0 06.13.2017 22:00:00 i53 32 2 10
1 06.13.2017 22:00:00 i32 32 2 10
2 06.13.2017 22:00:00 i32 4 2 8
5 06.13.2017 22:00:00 i20 7 7 22