0
0

More than 1 year has passed since last update.

polars dfの重複するindexの削除

Posted at

pandas

df = df[~df.index.duplicated()]

polars

polarsのdfにはインデックスが無いので、指定したカラムを対象に重複する行の削除を行う

df = pl.DataFrame(
    {
        "hoge": [1, 2, 2],
        "bar": [6, 7, 8],
        "ham": ["a", "b", "c"],
    }
)
df = df.drop_duplicates(subset="hoge")
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