Travis build: 145
This commit is contained in:
22
README.md
22
README.md
@ -39,6 +39,7 @@
|
|||||||
* [`every`](#every)
|
* [`every`](#every)
|
||||||
* [`every_nth`](#every_nth)
|
* [`every_nth`](#every_nth)
|
||||||
* [`filter_non_unique`](#filter_non_unique)
|
* [`filter_non_unique`](#filter_non_unique)
|
||||||
|
* [`filter_unique`](#filter_unique)
|
||||||
* [`flatten`](#flatten)
|
* [`flatten`](#flatten)
|
||||||
* [`group_by`](#group_by)
|
* [`group_by`](#group_by)
|
||||||
* [`has_duplicates`](#has_duplicates)
|
* [`has_duplicates`](#has_duplicates)
|
||||||
@ -478,6 +479,27 @@ filter_non_unique([1, 2, 2, 3, 4, 4, 5]) # [1, 3, 5]
|
|||||||
|
|
||||||
<br>[⬆ Back to top](#contents)
|
<br>[⬆ Back to top](#contents)
|
||||||
|
|
||||||
|
### filter_unique
|
||||||
|
|
||||||
|
Filters out the unique values in a list.
|
||||||
|
|
||||||
|
Use list comprehension and `list.count()` to create a list containing only the non-unique values.
|
||||||
|
|
||||||
|
```py
|
||||||
|
def filter_unique(lst):
|
||||||
|
return [x for x in set(item for item in lst if lst.count(item) > 1)]
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```py
|
||||||
|
filter_unique([1, 2, 2, 3, 4, 4, 5]) # [2, 4]
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#contents)
|
||||||
|
|
||||||
### flatten
|
### flatten
|
||||||
|
|
||||||
Flattens a list of lists once.
|
Flattens a list of lists once.
|
||||||
|
|||||||
@ -402,6 +402,21 @@
|
|||||||
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
|
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "filter_unique",
|
||||||
|
"type": "snippetListing",
|
||||||
|
"title": "filter_unique",
|
||||||
|
"attributes": {
|
||||||
|
"text": "Filters out the unique values in a list.\n\nUse list comprehension and `list.count()` to create a list containing only the non-unique values.\n\n",
|
||||||
|
"tags": [
|
||||||
|
"list",
|
||||||
|
"beginner"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"hash": "174c62134c81e139aa9d0b31f46c684b5edd4c52e721136d586d435058e19288"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "flatten",
|
"id": "flatten",
|
||||||
"type": "snippetListing",
|
"type": "snippetListing",
|
||||||
|
|||||||
@ -532,6 +532,26 @@
|
|||||||
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
|
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "filter_unique",
|
||||||
|
"title": "filter_unique",
|
||||||
|
"type": "snippet",
|
||||||
|
"attributes": {
|
||||||
|
"fileName": "filter_unique.md",
|
||||||
|
"text": "Filters out the unique values in a list.\n\nUse list comprehension and `list.count()` to create a list containing only the non-unique values.\n\n",
|
||||||
|
"codeBlocks": {
|
||||||
|
"code": "def filter_unique(lst):\n return [x for x in set(item for item in lst if lst.count(item) > 1)]",
|
||||||
|
"example": "filter_unique([1, 2, 2, 3, 4, 4, 5]) # [2, 4]"
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"list",
|
||||||
|
"beginner"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"hash": "174c62134c81e139aa9d0b31f46c684b5edd4c52e721136d586d435058e19288"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "flatten",
|
"id": "flatten",
|
||||||
"title": "flatten",
|
"title": "flatten",
|
||||||
|
|||||||
Reference in New Issue
Block a user