-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 79, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[[4, [22, 16, 11, 33], 24],\n", | ||
" [4, [12, 33, 87, 17], 14],\n", | ||
" [3, [92, 407, 25, 27], 34]]" | ||
] | ||
}, | ||
"execution_count": 79, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import numpy as np\n", | ||
"a = [\n", | ||
" [4, [22, 16, 11, 33], 24],\n", | ||
" [4, [12, 33, 87, 17], 14],\n", | ||
" [3, [92, 407, 25, 27], 34]\n", | ||
"]\n", | ||
"a" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 80, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"column1 = list(zip(*a))[1]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 88, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"['22|16|11|33', '12|33|87|17', '92|407|25|27']" | ||
] | ||
}, | ||
"execution_count": 88, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"newColumn1 = ['|'.join(str(e) for e in row) for row in column1]\n", | ||
"newColumn1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 89, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[(4, 4, 3), ['22|16|11|33', '12|33|87|17', '92|407|25|27'], (24, 14, 34)]" | ||
] | ||
}, | ||
"execution_count": 89, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"b = list(zip(*a))\n", | ||
"b[1] = newColumn1\n", | ||
"b" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 90, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[(4, '22|16|11|33', 24), (4, '12|33|87|17', 14), (3, '92|407|25|27', 34)]" | ||
] | ||
}, | ||
"execution_count": 90, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"a2 = list(zip(*b))\n", | ||
"a2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Imagine you have a output layer like this: | ||
a = [ | ||
[4, [22, 16, 11, 33], 24], | ||
[4, [12, 33, 87, 17], 14], | ||
[3, [92, 407, 25, 27], 34] | ||
] | ||
|
||
# "transpose" the list and get the second element | ||
column1 = list(zip(*a))[1] | ||
|
||
# Join all elements with | | ||
newColumn1 = ['|'.join(str(e) for e in row) for row in column1] | ||
|
||
# Put back the modified column | ||
b = list(zip(*a)) | ||
b[1] = newColumn1 | ||
|
||
# "Untranspose" your list | ||
a2 = list(zip(*b)) | ||
|