LoginSignup
0

More than 5 years have passed since last update.

【Python@Pandas】エラー"Try using .loc[row_indexer,col_indexer] = value instead"の回避策について

Last updated at Posted at 2017-10-11

df.dropnan() メーソドで、ある欄にNaNの値を含む行を削除すると、
全体のレコード数は減少しますが、indexの順番は単に削除された行をスキップだけです。
そのデータセットを使用して解析を行うと、以下のエラーメッセージが表示されます。
※結果への影響はないと思います。

A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

回避策として、df.reset_index() メーソドを使用して、データセットのindexを直すことで
事象を解消することができます。

参考資料

Returning a view versus a copy

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