Skip to content

Commit

Permalink
build based on 9633216
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Mar 20, 2023
1 parent 20c368e commit 21ef298
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions dev/data/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Handling Data · TheGraphData.jl</title><script data-outdated-warner src="../assets/warner.js"></script><link rel="canonical" href="https://semiotic-ai.github.io/TheGraphData.jl/data/"/><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../">TheGraphData.jl</a></span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><a class="tocitem" href="../querying/">Querying Clients</a></li><li><a class="tocitem" href="../io/">IO</a></li><li class="is-active"><a class="tocitem" href>Handling Data</a><ul class="internal"><li><a class="tocitem" href="#Cleaning-Queried-Data"><span>Cleaning Queried Data</span></a></li><li><a class="tocitem" href="#Reformatting-Queried-Data"><span>Reformatting Queried Data</span></a></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Handling Data</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Handling Data</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/main/docs/src/data.md#" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Handling-Data"><a class="docs-heading-anchor" href="#Handling-Data">Handling Data</a><a id="Handling-Data-1"></a><a class="docs-heading-anchor-permalink" href="#Handling-Data" title="Permalink"></a></h1><p>This section will take you through functions that will clean up your data just after querying it, as well as functions to convert your data into more friendly formats.</p><h2 id="Cleaning-Queried-Data"><a class="docs-heading-anchor" href="#Cleaning-Queried-Data">Cleaning Queried Data</a><a id="Cleaning-Queried-Data-1"></a><a class="docs-heading-anchor-permalink" href="#Cleaning-Queried-Data" title="Permalink"></a></h2><p>After querying data (<a href="../querying/#Querying-Clients">Querying Clients</a>), you&#39;ll have a vector of dictionaries. Because of the nature of GraphQL, each of these dictionaries might actually be nested dictionaries. Depending on your query and application, this nesting may prove to be a headache. When your nested dictionaries have unique keys, you can flatten the dictionary to be nicer to handle. Remember, you can apply this function to a vector of dictionaries by using the broadcast operator!</p><pre><code class="language-julia hljs">julia&gt; d = Dict(&quot;a&quot; =&gt; 1, &quot;b&quot; =&gt; Dict(&quot;c&quot; =&gt; Dict(&quot;d&quot; =&gt; 4)))
julia&gt; flatten(d)
Dict(&quot;a&quot; =&gt; 1, &quot;b.c.d&quot; =&gt; 4)</code></pre><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.flatten" href="#TheGraphData.flatten"><code>TheGraphData.flatten</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">flatten(d::Dict)</code></pre><p>Flatten a dictionary <code>d</code>.</p><p>For example, for <code>Dict(:a =&gt; Dict(:b =&gt; 2))</code>, the resulting dictionary would be <code>Dict(:(a.b) =&gt; 2)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/4842555796601dee6cda5042278bbda74221b0f0/src/data.jl#L46-L53">source</a></section></article><p>Given a dictionary or vector, you may also want to insert a key-value pair or element respectively if it isn&#39;t already set.</p><pre><code class="language-julia hljs">julia&gt; d = Dict(&quot;a&quot; =&gt; 1, &quot;b&quot; =&gt; 2)
Dict(&quot;a&quot; =&gt; 1, &quot;b.c.d&quot; =&gt; 4)</code></pre><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.flatten" href="#TheGraphData.flatten"><code>TheGraphData.flatten</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">flatten(d::Dict)</code></pre><p>Flatten a dictionary <code>d</code>.</p><p>For example, for <code>Dict(:a =&gt; Dict(:b =&gt; 2))</code>, the resulting dictionary would be <code>Dict(:(a.b) =&gt; 2)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/9633216cacd355f178d11947bba56131d282f716/src/data.jl#L46-L53">source</a></section></article><p>Given a dictionary or vector, you may also want to insert a key-value pair or element respectively if it isn&#39;t already set.</p><pre><code class="language-julia hljs">julia&gt; d = Dict(&quot;a&quot; =&gt; 1, &quot;b&quot; =&gt; 2)
julia&gt; d = setdefault!(d, &quot;c&quot;, 3)
Dict(&quot;a&quot; =&gt; 1, &quot;b&quot; =&gt; 2, &quot;c&quot; =&gt; 3)
julia&gt; d = setdefault!(d, &quot;c&quot;, 4)
Dict(&quot;a&quot; =&gt; 1, &quot;b&quot; =&gt; 2, &quot;c&quot; =&gt; 3)</code></pre><pre><code class="language-julia hljs">julia&gt; d = [&quot;a&quot;, &quot;b&quot;]
julia&gt; d = setdefault!(d, &quot;c&quot;)
[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]
julia&gt; d = setdefault!(d, &quot;c&quot;)
[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</code></pre><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.setdefault!" href="#TheGraphData.setdefault!"><code>TheGraphData.setdefault!</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">setdefault!(d::Dict, k, v)</code></pre><p>Set the value in the collection if it doesn&#39;t exist.</p><p>Similar to Python&#39;s <code>setdefault</code> when used on dictionaries. On vectors, this checks if the value is in the vector, and adds it if it isn&#39;t. This does not work on nested vectors.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/4842555796601dee6cda5042278bbda74221b0f0/src/data.jl#L69-L77">source</a></section></article><h2 id="Reformatting-Queried-Data"><a class="docs-heading-anchor" href="#Reformatting-Queried-Data">Reformatting Queried Data</a><a id="Reformatting-Queried-Data-1"></a><a class="docs-heading-anchor-permalink" href="#Reformatting-Queried-Data" title="Permalink"></a></h2><p>A vector of dictionaries is not the nicest data format to work with. To this end, we provide helper functions to put the data into nicer formats.</p><h3 id="TypedTable"><a class="docs-heading-anchor" href="#TypedTable">TypedTable</a><a id="TypedTable-1"></a><a class="docs-heading-anchor-permalink" href="#TypedTable" title="Permalink"></a></h3><p>In Julia, the <a href="https://github.com/JuliaData/Tables.jl">Tables.jl</a> interface is quite powerful. Hence, you may find it useful to format your data as a <a href="https://typedtables.juliadata.org/stable/">TypedTable</a>. Note that these tables are immutable. They&#39;re more efficient if you&#39;re not going to be copying your data around for mutation since the compiler can infer column names and types. However, if you plan on mutating your table, use FlexTable instead. Once your data is a TypedTable, you can use packages like <a href="https://github.com/JuliaData/SplitApplyCombine.jl">SplitApplyCombine.jl</a> to manipulate your data. A typical workflow using the default client from beginning to TypedTable might look like</p><pre><code class="language-julia hljs">julia&gt; qvalue = &quot;indexers&quot;
[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</code></pre><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.setdefault!" href="#TheGraphData.setdefault!"><code>TheGraphData.setdefault!</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">setdefault!(d::Dict, k, v)</code></pre><p>Set the value in the collection if it doesn&#39;t exist.</p><p>Similar to Python&#39;s <code>setdefault</code> when used on dictionaries. On vectors, this checks if the value is in the vector, and adds it if it isn&#39;t. This does not work on nested vectors.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/9633216cacd355f178d11947bba56131d282f716/src/data.jl#L69-L77">source</a></section></article><h2 id="Reformatting-Queried-Data"><a class="docs-heading-anchor" href="#Reformatting-Queried-Data">Reformatting Queried Data</a><a id="Reformatting-Queried-Data-1"></a><a class="docs-heading-anchor-permalink" href="#Reformatting-Queried-Data" title="Permalink"></a></h2><p>A vector of dictionaries is not the nicest data format to work with. To this end, we provide helper functions to put the data into nicer formats.</p><h3 id="TypedTable"><a class="docs-heading-anchor" href="#TypedTable">TypedTable</a><a id="TypedTable-1"></a><a class="docs-heading-anchor-permalink" href="#TypedTable" title="Permalink"></a></h3><p>In Julia, the <a href="https://github.com/JuliaData/Tables.jl">Tables.jl</a> interface is quite powerful. Hence, you may find it useful to format your data as a <a href="https://typedtables.juliadata.org/stable/">TypedTable</a>. Note that these tables are immutable. They&#39;re more efficient if you&#39;re not going to be copying your data around for mutation since the compiler can infer column names and types. However, if you plan on mutating your table, use FlexTable instead. Once your data is a TypedTable, you can use packages like <a href="https://github.com/JuliaData/SplitApplyCombine.jl">SplitApplyCombine.jl</a> to manipulate your data. A typical workflow using the default client from beginning to TypedTable might look like</p><pre><code class="language-julia hljs">julia&gt; qvalue = &quot;indexers&quot;
julia&gt; qargs = Dict(&quot;first&quot; =&gt; 1)
julia&gt; qfields = [&quot;id&quot;]
julia&gt; query(qvalue, qargs, qfields) .|&gt; flatten |&gt; table
Expand All @@ -18,6 +18,6 @@
┌───────────────────────────────────────────
1 │ 0x011bdfea664ece919d895d174f57331460056236</code></pre><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.table" href="#TheGraphData.table"><code>TheGraphData.table</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">table(d::AbstractVector{D}) where {D&lt;:Dict}
table(d::CSV.File)
table(d::NamedTuple)</code></pre><p>Convert the queried data <code>d</code> to a TypedTable.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/4842555796601dee6cda5042278bbda74221b0f0/src/data.jl#L16-L22">source</a></section></article><h3 id="FlexTable"><a class="docs-heading-anchor" href="#FlexTable">FlexTable</a><a id="FlexTable-1"></a><a class="docs-heading-anchor-permalink" href="#FlexTable" title="Permalink"></a></h3><p>This is similar to TypedTable above, except it supports mutation.</p><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.flextable" href="#TheGraphData.flextable"><code>TheGraphData.flextable</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">flextable(d::AbstractVector{D}) where {D&lt;:Dict}
table(d::NamedTuple)</code></pre><p>Convert the queried data <code>d</code> to a TypedTable.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/9633216cacd355f178d11947bba56131d282f716/src/data.jl#L16-L22">source</a></section></article><h3 id="FlexTable"><a class="docs-heading-anchor" href="#FlexTable">FlexTable</a><a id="FlexTable-1"></a><a class="docs-heading-anchor-permalink" href="#FlexTable" title="Permalink"></a></h3><p>This is similar to TypedTable above, except it supports mutation.</p><article class="docstring"><header><a class="docstring-binding" id="TheGraphData.flextable" href="#TheGraphData.flextable"><code>TheGraphData.flextable</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">flextable(d::AbstractVector{D}) where {D&lt;:Dict}
flextable(d::CSV.File)
flextable(d::NamedTuple)</code></pre><p>Convert the queried data <code>d</code> to a FlexTable.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/4842555796601dee6cda5042278bbda74221b0f0/src/data.jl#L31-L37">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../io/">« IO</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.23 on <span class="colophon-date" title="Wednesday 30 November 2022 21:37">Wednesday 30 November 2022</span>. Using Julia version 1.8.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
flextable(d::NamedTuple)</code></pre><p>Convert the queried data <code>d</code> to a FlexTable.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/semiotic-ai/TheGraphData.jl/blob/9633216cacd355f178d11947bba56131d282f716/src/data.jl#L31-L37">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../io/">« IO</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.23 on <span class="colophon-date" title="Monday 20 March 2023 17:44">Monday 20 March 2023</span>. Using Julia version 1.8.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 21ef298

Please sign in to comment.