0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PandasのDataFrameやSeriesで重複要素を取り除く方法

Posted at

初投稿かつ備忘録として残しておく。
といっても、参考になったサイトのURLを残すだけ。

〇参考URL
https://qiita.com/kira4845/items/6798e54eb76b15329e3c
〇やりたいこと
 ・データフレームdfの特定の列col_aの重複要素を削除したい。
・重複のないデータフレームをdf2とする。
・df=(col_a , col_b , col_c,
0 , 0 , 0 ,
1 , 2 , 0 ,
0 , 5 , 3 )
・df2=(col_a , col_b , col_c,
0 , 0 , 0 ,
1 , 2 , 0 )

〇解決方法
・drop_duplicatesというメソッドを使用する。
  df2 = df.drop_duplicates(subset="col_a")

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?