You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: customize-pins-metadata.html
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -190,7 +190,7 @@ <h1 class="title">Create consistent metadata for pins</h1>
190
190
191
191
<p>The <code>metadata</code> argument in pins is flexible and can hold any kind of metadata that you can formulate as a <code>dict</code> (convertable to JSON). In some situations, you may want to read and write with <em>consistent</em> customized metadata; you can create functions to wrap <ahref="./reference/pin_write.html#pins.boards.BaseBoard.pin_write"><code>pin_write</code></a> and <ahref="./reference/pin_read.html#pins.boards.BaseBoard.pin_read"><code>pin_read</code></a> for your particular use case.</p>
192
192
<p>We’ll begin by creating a temporary board for demonstration:</p>
<spanid="cb2-3"><ahref="#cb2-3" aria-hidden="true" tabindex="-1"></a>some_cat.categories</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
@@ -212,7 +212,7 @@ <h1>A function to store pandas Categoricals</h1>
212
212
</div>
213
213
<p>Notice that the categories attribute is just the unique values in the categorical.</p>
214
214
<p>We can write a function wrapping <ahref="./reference/pin_write.html#pins.boards.BaseBoard.pin_write"><code>pin_write</code></a> that holds the categories in metadata, so we can easily re-create the categorical with them.</p>
<spanid="cb5-2"><ahref="#cb5-2" aria-hidden="true" tabindex="-1"></a>pin_write_cat_json(board, some_cat, name <spanclass="op">=</span><spanclass="st">"some-cat"</span>)</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
230
230
<divclass="cell-output cell-output-stderr">
231
-
<pre><code>/tmp/ipykernel_2102/2180373110.py:8: FutureWarning: Categorical.to_list is deprecated and will be removed in a future version. Use obj.tolist() instead
231
+
<pre><code>/tmp/ipykernel_2004/2180373110.py:8: FutureWarning: Categorical.to_list is deprecated and will be removed in a future version. Use obj.tolist() instead
<h2class="anchored" data-anchor-id="a-function-to-read-categoricals">A function to read categoricals</h2>
240
240
<p>It’s possible to read this pin using the regular <ahref="./reference/pin_read.html#pins.boards.BaseBoard.pin_read"><code>pin_read</code></a> function, but the object we get is no longer a categorical!</p>
<p>However, notice that if we use <ahref="./reference/pin_meta.html#pins.boards.BaseBoard.pin_meta"><code>pin_meta</code></a>, the information we stored on categories is in the <code>.user</code> field.</p>
0 commit comments