Skip to content

Commit

Permalink
Deploying to gh-pages from @ e8fb6d2 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
github-merge-queue[bot] committed Mar 12, 2024
1 parent eea50c2 commit 8bc355a
Show file tree
Hide file tree
Showing 53 changed files with 24,682 additions and 19,435 deletions.
29 changes: 29 additions & 0 deletions _modules/arkouda/categorical.html
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,35 @@ <h1>Source code for arkouda.categorical</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to_ndarray</span><span class="p">()</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span></div>


<div class="viewcode-block" id="Categorical.to_strings">
<a class="viewcode-back" href="../../autoapi/arkouda/index.html#arkouda.categorical.Categorical.to_strings">[docs]</a>
<span class="k">def</span> <span class="nf">to_strings</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Convert the Categorical to Strings.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> arkouda.strings.Strings</span>
<span class="sd"> A Strings object corresponding to the values in</span>
<span class="sd"> this Categorical.</span>

<span class="sd"> Examples</span>
<span class="sd"> --------</span>
<span class="sd"> &gt;&gt;&gt; from arkouda import ak</span>
<span class="sd"> &gt;&gt;&gt; ak.connect()</span>
<span class="sd"> &gt;&gt;&gt; a = ak.array([&quot;a&quot;,&quot;b&quot;,&quot;c&quot;])</span>
<span class="sd"> &gt;&gt;&gt; a</span>
<span class="sd"> &gt;&gt;&gt; c = ak.Categorical(a)</span>
<span class="sd"> &gt;&gt;&gt; c.to_strings()</span>
<span class="sd"> c.to_strings()</span>

<span class="sd"> &gt;&gt;&gt; isinstance(c.to_strings(), ak.Strings)</span>
<span class="sd"> True</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">categories</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">codes</span><span class="p">]</span></div>


<span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span>
<span class="s2">&quot;Categorical does not support iteration. To force data transfer from server, use to_ndarray&quot;</span>
Expand Down
5 changes: 1 addition & 4 deletions _modules/arkouda/logger.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,6 @@ <h1>Source code for arkouda.logger</h1><div class="highlight"><pre>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;The name </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> does not match any handler&quot;</span><span class="p">)</span>


<div class="viewcode-block" id="getArkoudaLogger">
<a class="viewcode-back" href="../../autoapi/arkouda/index.html#arkouda.getArkoudaLogger">[docs]</a>
<span class="nd">@typechecked</span>
<span class="k">def</span> <span class="nf">getArkoudaLogger</span><span class="p">(</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
Expand Down Expand Up @@ -569,8 +567,7 @@ <h1>Source code for arkouda.logger</h1><div class="highlight"><pre>

<span class="n">logger</span> <span class="o">=</span> <span class="n">ArkoudaLogger</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">handlers</span><span class="o">=</span><span class="n">handlers</span><span class="p">,</span> <span class="n">logFormat</span><span class="o">=</span><span class="n">logFormat</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">logLevel</span><span class="p">)</span>
<span class="n">loggers</span><span class="p">[</span><span class="n">logger</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">logger</span>
<span class="k">return</span> <span class="n">logger</span></div>

<span class="k">return</span> <span class="n">logger</span>


<span class="nd">@typechecked</span>
Expand Down
176 changes: 91 additions & 85 deletions _modules/arkouda/pdarrayclass.html

Large diffs are not rendered by default.

104 changes: 52 additions & 52 deletions _modules/arkouda/segarray.html

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions _modules/arkouda/series.html
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,124 @@ <h1>Source code for arkouda.series</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">Series</span><span class="p">(</span><span class="n">index</span><span class="o">=</span><span class="n">idx</span><span class="o">.</span><span class="n">index</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">v</span><span class="p">)</span></div>


<div class="viewcode-block" id="Series.map">
<a class="viewcode-back" href="../../autoapi/arkouda/series/index.html#arkouda.Series.map">[docs]</a>
<span class="k">def</span> <span class="nf">map</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">arg</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">dict</span><span class="p">,</span> <span class="n">Series</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">Series</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Map values of Series according to an input mapping.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> arg : dict or Series</span>
<span class="sd"> The mapping correspondence.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> arkouda.series.Series</span>
<span class="sd"> A new series with the same index as the caller.</span>
<span class="sd"> When the input Series has Categorical values,</span>
<span class="sd"> the return Series will have Strings values.</span>
<span class="sd"> Otherwise, the return type will match the input type.</span>
<span class="sd"> Raises</span>
<span class="sd"> ------</span>
<span class="sd"> TypeError</span>
<span class="sd"> Raised if arg is not of type dict or arkouda.Series.</span>
<span class="sd"> Raised if arg values not of type pdarray or Strings.</span>
<span class="sd"> Examples</span>
<span class="sd"> --------</span>
<span class="sd"> &gt;&gt;&gt; import arkouda as ak</span>
<span class="sd"> &gt;&gt;&gt; ak.connect()</span>
<span class="sd"> &gt;&gt;&gt; s = ak.Series(ak.array([2, 3, 2, 3, 4]))</span>
<span class="sd"> &gt;&gt;&gt; display(s)</span>

<span class="sd"> +----+-----+</span>
<span class="sd"> | | 0 |</span>
<span class="sd"> +====+=====+</span>
<span class="sd"> | 0 | 2 |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 1 | 3 |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 2 | 2 |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 3 | 3 |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 4 | 4 |</span>
<span class="sd"> +----+-----+</span>

<span class="sd"> &gt;&gt;&gt; s.map({4: 25.0, 2: 30.0, 1: 7.0, 3: 5.0})</span>

<span class="sd"> +----+-----+</span>
<span class="sd"> | | 0 |</span>
<span class="sd"> +====+=====+</span>
<span class="sd"> | 0 | 30.0|</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 1 | 5.0 |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 2 | 30.0|</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 3 | 5.0 |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 4 | 25.0|</span>
<span class="sd"> +----+-----+</span>

<span class="sd"> &gt;&gt;&gt; s2 = ak.Series(ak.array([&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;]), index = ak.array([4,2,1,3]))</span>
<span class="sd"> &gt;&gt;&gt; s.map(s2)</span>

<span class="sd"> +----+-----+</span>
<span class="sd"> | | 0 |</span>
<span class="sd"> +====+=====+</span>
<span class="sd"> | 0 | b |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 1 | b |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 2 | d |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 3 | d |</span>
<span class="sd"> +----+-----+</span>
<span class="sd"> | 4 | a |</span>
<span class="sd"> +----+-----+</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">arkouda</span> <span class="kn">import</span> <span class="n">Series</span><span class="p">,</span> <span class="n">broadcast</span><span class="p">,</span> <span class="n">full</span>

<span class="n">keys</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">values</span>
<span class="n">gb</span> <span class="o">=</span> <span class="n">GroupBy</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">dropna</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">gb_keys</span> <span class="o">=</span> <span class="n">gb</span><span class="o">.</span><span class="n">unique_keys</span>

<span class="n">mapping</span> <span class="o">=</span> <span class="n">arg</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
<span class="n">mapping</span> <span class="o">=</span> <span class="n">Series</span><span class="p">([</span><span class="n">array</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">mapping</span><span class="o">.</span><span class="n">keys</span><span class="p">())),</span> <span class="n">array</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">mapping</span><span class="o">.</span><span class="n">values</span><span class="p">()))])</span>

<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="n">Series</span><span class="p">):</span>
<span class="n">xtra_keys</span> <span class="o">=</span> <span class="n">gb_keys</span><span class="p">[</span><span class="n">in1d</span><span class="p">(</span><span class="n">gb_keys</span><span class="p">,</span> <span class="n">mapping</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="n">invert</span><span class="o">=</span><span class="kc">True</span><span class="p">)]</span>

<span class="k">if</span> <span class="n">xtra_keys</span><span class="o">.</span><span class="n">size</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="p">(</span><span class="n">Strings</span><span class="p">,</span> <span class="n">Categorical</span><span class="p">)):</span>
<span class="n">nans</span> <span class="o">=</span> <span class="n">full</span><span class="p">(</span><span class="n">xtra_keys</span><span class="o">.</span><span class="n">size</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span> <span class="n">mapping</span><span class="o">.</span><span class="n">values</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">nans</span> <span class="o">=</span> <span class="n">full</span><span class="p">(</span><span class="n">xtra_keys</span><span class="o">.</span><span class="n">size</span><span class="p">,</span> <span class="s2">&quot;null&quot;</span><span class="p">)</span>

<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">xtra_keys</span><span class="p">,</span> <span class="n">Categorical</span><span class="p">):</span>
<span class="n">xtra_keys</span> <span class="o">=</span> <span class="n">xtra_keys</span><span class="o">.</span><span class="n">to_strings</span><span class="p">()</span>

<span class="n">xtra_series</span> <span class="o">=</span> <span class="n">Series</span><span class="p">(</span><span class="n">nans</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="n">xtra_keys</span><span class="p">)</span>
<span class="n">mapping</span> <span class="o">=</span> <span class="n">Series</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">mapping</span><span class="p">,</span> <span class="n">xtra_series</span><span class="p">])</span>

<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">gb_keys</span><span class="p">,</span> <span class="n">Categorical</span><span class="p">):</span>
<span class="n">mapping</span> <span class="o">=</span> <span class="n">mapping</span><span class="p">[</span><span class="n">gb_keys</span><span class="o">.</span><span class="n">to_strings</span><span class="p">()]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">mapping</span> <span class="o">=</span> <span class="n">mapping</span><span class="p">[</span><span class="n">gb_keys</span><span class="p">]</span>

<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="p">(</span><span class="n">pdarray</span><span class="p">,</span> <span class="n">Strings</span><span class="p">)):</span>
<span class="k">return</span> <span class="n">Series</span><span class="p">(</span>
<span class="n">broadcast</span><span class="p">(</span><span class="n">gb</span><span class="o">.</span><span class="n">segments</span><span class="p">,</span> <span class="n">mapping</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="n">permutation</span><span class="o">=</span><span class="n">gb</span><span class="o">.</span><span class="n">permutation</span><span class="p">),</span> <span class="n">index</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">index</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Map values must be castable to pdarray or Strings.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Map must be dict or arkouda.Series.&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="Series.pdconcat">
<a class="viewcode-back" href="../../autoapi/arkouda/series/index.html#arkouda.Series.pdconcat">[docs]</a>
<span class="nd">@staticmethod</span>
Expand Down
22 changes: 22 additions & 0 deletions _sources/autoapi/arkouda/categorical/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,28 @@ Classes
.. seealso:: :obj:`to_hdf`


.. py:method:: to_strings() -> List
Convert the Categorical to Strings.

:returns: A Strings object corresponding to the values in
this Categorical.
:rtype: arkouda.strings.Strings

.. rubric:: Examples

>>> from arkouda import ak
>>> ak.connect()
>>> a = ak.array(["a","b","c"])
>>> a
>>> c = ak.Categorical(a)
>>> c.to_strings()
c.to_strings()

>>> isinstance(c.to_strings(), ak.Strings)
True


.. py:method:: transfer(hostname: str, port: arkouda.dtypes.int_scalars)
Sends a Categorical object to a different Arkouda server
Expand Down
Loading

0 comments on commit 8bc355a

Please sign in to comment.