Skip to content

Commit

Permalink
fix patch example in the Dataframe notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Oct 16, 2023
1 parent 3cba0b7 commit 159c0d1
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions examples/reference/widgets/DataFrame.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import pandas as pd\n",
Expand Down Expand Up @@ -81,7 +83,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"df = pd.DataFrame({'int': [1, 2, 3], 'float': [3.14, 6.28, 9.42], 'str': ['A', 'B', 'C'], 'bool': [True, False, True]}, index=[1, 2, 3])\n",
Expand All @@ -101,7 +105,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from bokeh.models.widgets.tables import SelectEditor, NumberFormatter\n",
Expand All @@ -123,7 +129,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"table.selection = [0, 2]\n",
Expand All @@ -147,7 +155,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"custom_df = pd._testing.makeMixedDataFrame()\n",
Expand All @@ -167,7 +177,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"pn.widgets.DataFrame(custom_df, autosize_mode='fit_columns', width=300)"
Expand All @@ -185,7 +197,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"pn.widgets.DataFrame(custom_df, autosize_mode='fit_viewport')"
Expand All @@ -207,7 +221,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"date_df = pd._testing.makeTimeDataFrame()\n",
Expand All @@ -227,7 +243,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"agg_df = pd.concat([date_df, date_df.median().to_frame('Median').T, date_df.mean().to_frame('Mean').T])\n",
Expand All @@ -250,7 +268,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from bokeh.sampledata.population import data as population_data \n",
Expand All @@ -272,7 +292,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand All @@ -293,7 +315,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def stream_data():\n",
Expand All @@ -315,7 +339,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"patch_table = pn.widgets.DataFrame(df[['int', 'float', 'str', 'bool']])\n",
Expand All @@ -342,7 +368,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"patch_table.patch({\n",
Expand All @@ -353,7 +381,7 @@
" 'int': [\n",
" (slice(0, 2), [3, 2])\n",
" ]\n",
"})"
"}, as_index=False)"
]
},
{
Expand Down

0 comments on commit 159c0d1

Please sign in to comment.