LoginSignup
3
1

More than 5 years have passed since last update.

【Python】list, pandas.Seriesの重複を削除する

Last updated at Posted at 2016-07-07

listやpandas.Seriesで重複を削除する際に意外とハマったので。

# pandas.Seriesでも同様
ls = [1, 2, 3, 1, 2, 3, 4]

set(ls) # listから集合にする
出力結果
{1, 2, 3, 4}

集合だとインデクシングできないので,必要ならlist()で再度リストに戻す。

list(set(ls))
出力結果
[1, 2, 3, 4]
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1