LoginSignup
0
1

More than 1 year has passed since last update.

機械学習勉強記録 Pandasで重複する行を除外する

Posted at

1 重複する行を消す .drop_duplicates()

データフレームの中で、重複したデータが入っている時に、それを簡単に削除する方法があります。
.drop_duplicates()を使います。

df.drop_duplicates()

2 パラメータ

2.1 subset

例えば、subset=['Name']とすると、'Name'の列で同じ要素を持った(二回目以降に同じ要素が出てきた)行が消えます。

2.2 keep

keep='last'重複したもののなかでも、最後の一つだけを残して、他は全て消えます。
keep=False重複したものは何も残らず、全て消えます。

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