相关疑难解决方法(0)

熊猫:丢掉连续的重复

在熊猫中只删除连续重复的最有效方法是什么?

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)

python pandas

50
推荐指数
4
解决办法
1万
查看次数

标签 统计

pandas ×1

python ×1