|
|
长情的充电器 · vim显示^@是什么意思啊? - 知乎· 2 年前 · |
|
|
慈祥的紫菜汤 · Java 实例 – ...· 3 年前 · |
|
|
行走的眼镜 · Python读取Yaml文件_51CTO博客 ...· 3 年前 · |
|
|
光明磊落的豆腐 · TypeORM cascade ...· 3 年前 · |
Drop duplicate rows from this dataframe.
Column name(s) or selector(s), to consider when identifying
duplicate rows. If set to
None
(default), use all columns.
Which of the duplicate rows to keep.
This allows more optimizations.
‘none’: Don’t keep duplicate rows.
‘first’: Keep first unique row.
‘last’: Keep last unique row.
Keep the same order as the original DataFrame. This is more expensive to
compute.
Settings this to
True
blocks the possibility
to run on the streaming engine.
DataFrame with unique rows.
Warning
This method will fail if there is a column of type
List
in the DataFrame or
subset.
Examples
>>> df = pl.DataFrame(
... {
... "foo": [1, 2, 3, 1],
... "bar": ["a", "a", "a", "a"],
... "ham": ["b", "b", "b", "b"],
... }
... )
>>> df.unique(maintain_order=True)
shape: (3, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ ham │
│ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ str │
╞═════╪═════╪═════╡
│ 1 ┆ a ┆ b │
│ 2 ┆ a ┆ b │
│ 3 ┆ a ┆ b │
└─────┴─────┴─────┘
>>> df.unique(subset=["bar", "ham"], maintain_order=True)
shape: (1, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ ham │
│ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ str │
╞═════╪═════╪═════╡
│ 1 ┆ a ┆ b │
└─────┴─────┴─────┘
>>> df.unique(keep="last", maintain_order=True)
shape: (3, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ ham │
│ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ str │
╞═════╪═════╪═════╡
│ 2 ┆ a ┆ b │
│ 3 ┆ a ┆ b │
│ 1 ┆ a ┆ b │
└─────┴─────┴─────┘
|
|
长情的充电器 · vim显示^@是什么意思啊? - 知乎 2 年前 |