Skip to content

Commit

Permalink
fix deepnote link
Browse files Browse the repository at this point in the history
  • Loading branch information
khuyentran1401 committed Oct 27, 2021
1 parent 7638ea1 commit fe7b037
Show file tree
Hide file tree
Showing 3 changed files with 399 additions and 26,112 deletions.
52 changes: 25 additions & 27 deletions productive_tools/pipe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"cells": [
{
"cell_type": "markdown",
"source": "[![View on GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/khuyentran1401/Data-science/blob/master/productive_tools/pipe.ipynb)\n\n[<img src=\"https://deepnote.com/buttons/launch-in-deepnote.svg\">](/work/Data-science/productive_tools/pipe.ipynb)",
"source": "[![View on GitHub](https://img.shields.io/badge/GitHub-View_on_GitHub-blue?logo=GitHub)](https://github.com/khuyentran1401/Data-science/blob/master/productive_tools/pipe.ipynb)\n\n[<img src=\"https://deepnote.com/buttons/launch-in-deepnote.svg\">](https://deepnote.com/project/Data-science-hxlyJpi-QrKFJziQgoMSmQ/%2FData-science%2Fproductive_tools%2Fpipe.ipynb)",
"metadata": {
"tags": [],
"cell_id": "00000-2c4341ee-abf7-4f9b-af8d-48afb0d90081",
"deepnote_cell_type": "markdown"
},
"outputs": [],
"execution_count": null
}
},
{
"cell_type": "code",
Expand Down Expand Up @@ -52,7 +50,7 @@
"deepnote_cell_type": "code"
},
"source": "from pipe import where",
"execution_count": 1,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -66,7 +64,7 @@
"deepnote_cell_type": "code"
},
"source": "arr = [1, 2, 3, 4, 5]\n\n# filter using list comprehension\n[x for x in arr if x % 2 == 0]",
"execution_count": 2,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -89,7 +87,7 @@
"deepnote_cell_type": "code"
},
"source": "# filter using pipe\nlist(arr | where(lambda x: x % 2 == 0))",
"execution_count": 3,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -120,7 +118,7 @@
"deepnote_cell_type": "code"
},
"source": "from pipe import select",
"execution_count": 2,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -134,7 +132,7 @@
"deepnote_cell_type": "code"
},
"source": "arr = [1, 2, 3, 4, 5]",
"execution_count": 45,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -157,7 +155,7 @@
"deepnote_cell_type": "code"
},
"source": "list(arr | select(lambda x: x * 2))",
"execution_count": 47,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -188,7 +186,7 @@
"deepnote_cell_type": "code"
},
"source": "# Instead of this\nlist(map(lambda x: x * 2, filter(lambda x: x % 2 == 0, arr)))",
"execution_count": 46,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -219,7 +217,7 @@
"deepnote_cell_type": "code"
},
"source": "# use pipe\nlist(arr | where(lambda x: x % 2 == 0) | select(lambda x: x * 2))",
"execution_count": 7,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -242,7 +240,7 @@
"deepnote_cell_type": "code"
},
"source": "# the order matters\nlist(arr | select(lambda x: x * 2) | where(lambda x: x % 2 == 0))",
"execution_count": 8,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -281,7 +279,7 @@
"deepnote_cell_type": "code"
},
"source": "from pipe import chain",
"execution_count": 28,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -304,7 +302,7 @@
"deepnote_cell_type": "code"
},
"source": "nested = [[1, 2, [3]], [4, 5]]\nlist(nested | chain)",
"execution_count": 48,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -343,7 +341,7 @@
"deepnote_cell_type": "code"
},
"source": "from pipe import traverse",
"execution_count": 49,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -366,7 +364,7 @@
"deepnote_cell_type": "code"
},
"source": "list(nested | traverse)",
"execution_count": 50,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -397,7 +395,7 @@
"deepnote_cell_type": "code"
},
"source": "fruits = [\n {\"name\": \"apple\", \"price\": [2, 5]},\n {\"name\": \"orange\", \"price\": 4},\n {\"name\": \"grape\", \"price\": 5},\n]",
"execution_count": 27,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -420,7 +418,7 @@
"deepnote_cell_type": "code"
},
"source": "list(fruits | select(lambda fruit: fruit[\"price\"]) | traverse)",
"execution_count": 36,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -459,7 +457,7 @@
"deepnote_cell_type": "code"
},
"source": "from pipe import groupby",
"execution_count": 3,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -474,7 +472,7 @@
"deepnote_cell_type": "code"
},
"source": "list(\n (1, 2, 3, 4, 5, 6, 7, 8, 9)\n | groupby(lambda x: \"Even\" if x % 2==0 else \"Odd\")\n | select(lambda x: {x[0]: list(x[1])})\n)",
"execution_count": 11,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -497,7 +495,7 @@
"deepnote_cell_type": "code"
},
"source": "list(\n (1, 2, 3, 4, 5, 6, 7, 8, 9)\n | groupby(lambda x: \"Even\" if x % 2==0 else \"Odd\")\n | select(lambda x: {x[0]: list(x[1] | where(lambda x: x > 2))})\n)",
"execution_count": 12,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -528,7 +526,7 @@
"deepnote_cell_type": "code"
},
"source": "from pipe import dedup\n\narr = [1, 2, 2, 3, 4, 5, 6, 6, 7, 9, 3, 3, 1]",
"execution_count": 15,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -551,7 +549,7 @@
"deepnote_cell_type": "code"
},
"source": "list(arr | dedup)",
"execution_count": 33,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -574,7 +572,7 @@
"deepnote_cell_type": "code"
},
"source": "# Get one element that is smaller than 5 and one element that is larger than or equal to 5\nlist(arr | dedup(lambda key: key < 5))",
"execution_count": 26,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down Expand Up @@ -605,7 +603,7 @@
"deepnote_cell_type": "code"
},
"source": "data = [\n {\"name\": \"apple\", \"count\": 2},\n {\"name\": \"orange\", \"count\": 4},\n {\"name\": \"grape\", \"count\": None},\n {\"name\": \"orange\", \"count\": 7},\n]",
"execution_count": 12,
"execution_count": null,
"outputs": [
{
"data": {
Expand All @@ -628,7 +626,7 @@
"deepnote_cell_type": "code"
},
"source": "list(\n data\n | dedup(key=lambda fruit: fruit[\"name\"])\n | select(lambda fruit: fruit[\"count\"])\n | where(lambda count: isinstance(count, int))\n)",
"execution_count": 16,
"execution_count": null,
"outputs": [
{
"data": {
Expand Down
Loading

0 comments on commit fe7b037

Please sign in to comment.