Created
June 8, 2016 22:39
-
-
Save lbustelo/916de756aad52bc771cf7b56068e6ccf to your computer and use it in GitHub Desktop.
declarativewidgets issue #379
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# DeclarativeWidgets DataFrame Sync Test 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/opt/conda/lib/python3.5/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n", | |
" warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\n", | |
"/opt/conda/lib/python3.5/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n", | |
" warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\n" | |
] | |
} | |
], | |
"source": [ | |
"from IPython.core.display import HTML, display, clear_output\n", | |
"import pandas as pd\n", | |
"# pd.show_versions()\n", | |
"\n", | |
"%matplotlib inline" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<link rel=\"import\" href=\"urth_components/urth-viz-table/urth-viz-table.html\" is=\"urth-core-import\">\n", | |
"<link rel=\"import\" href=\"urth_components/juicy-html/juicy-html.html\" is=\"urth-core-import\" package=\"Juicy/juicy-html\">" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"%%html\n", | |
"<link rel=\"import\" href=\"urth_components/urth-viz-table/urth-viz-table.html\" is=\"urth-core-import\">\n", | |
"<link rel=\"import\" href=\"urth_components/juicy-html/juicy-html.html\" is=\"urth-core-import\" package=\"Juicy/juicy-html\">" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"df1 = pd.DataFrame([[1,2],[3,4]], columns=['a','b'])\n", | |
"df1.columns.name = 'df1'\n", | |
"df2 = pd.DataFrame([[5,6],[7,8]], columns=['c','d'])\n", | |
"df2.columns.name = 'df2'\n", | |
"df3 = pd.DataFrame([[9,10],[11,12]], columns=['e','f'])\n", | |
"df3.columns.name = 'df3'\n", | |
"df2_orig = df2.copy()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def print_df(idx:int):\n", | |
" global df1, df2, df3\n", | |
" #clear_output()\n", | |
" #print(idx)\n", | |
" if idx > 1:\n", | |
" return df3.style.set_properties(subset=['f'], **{'background-color': 'pink'}).render() \n", | |
" else:\n", | |
" return df2.style.set_properties(subset=['c'], **{'background-color': 'pink'}).render() " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<template is=\"urth-core-bind\">\n", | |
" <urth-core-dataframe id='df1' ref=\"df1\" value=\"{{df1}}\" auto></urth-core-dataframe>\n", | |
" <urth-viz-table datarows=\"{{df1.data}}\" columns=\"{{df1.columns}}\" selection=\"{{sel1}}\" rows-visible=6>\n", | |
" </urth-viz-table>\n", | |
"</template>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"%%html\n", | |
"<template is=\"urth-core-bind\">\n", | |
" <urth-core-dataframe id='df1' ref=\"df1\" value=\"{{df1}}\" auto></urth-core-dataframe>\n", | |
" <urth-viz-table datarows=\"{{df1.data}}\" columns=\"{{df1.columns}}\" selection=\"{{sel1}}\" rows-visible=6>\n", | |
" </urth-viz-table>\n", | |
"</template>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<template is=\"urth-core-bind\">\n", | |
" <template is=\"dom-if\" if=\"{{sel1}}\" auto>\n", | |
" <urth-core-function ref=\"print_df\" arg-idx=\"[[sel1.0]]\" result=\"{{df_out}}\" auto>\n", | |
" </urth-core-function>\n", | |
" <template is=\"juicy-html\" content$=\"{{df_out}}\"></template>\n", | |
" </template>\n", | |
"</template>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"%%html\n", | |
"<template is=\"urth-core-bind\">\n", | |
" <template is=\"dom-if\" if=\"{{sel1}}\" auto>\n", | |
" <urth-core-function ref=\"print_df\" arg-idx=\"[[sel1.0]]\" result=\"{{df_out}}\" auto>\n", | |
" </urth-core-function>\n", | |
" <template is=\"juicy-html\" content$=\"{{df_out}}\"></template>\n", | |
" </template>\n", | |
"</template>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"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.5.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment