在熊猫中只删除连续重复的最有效方法是什么?
drop_duplicates给出了这个:
In [3]: a = pandas.Series([1,2,2,3,2], index=[1,2,3,4,5])
In [4]: a.drop_duplicates()
Out[4]:
1 1
2 2
4 3
dtype: int64
Run Code Online (Sandbox Code Playgroud)
但我想要这个:
In [4]: a.something()
Out[4]:
1 1
2 2
4 3
5 2
dtype: int64
Run Code Online (Sandbox Code Playgroud)