Browse Source

Pandas

pull/57/head
Jure Šorn 4 years ago
parent
commit
92486a4196
3 changed files with 26 additions and 22 deletions
  1. 15
      README.md
  2. 17
      index.html
  3. 16
      parse.js

15
README.md

@ -3129,7 +3129,7 @@ y 2
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
| | 'sum' | ['sum'] | {'s': 'sum'} | | | 'sum' | ['sum'] | {'s': 'sum'} |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
| sr.apply(…) | 3 | sum 3 | s 3 |
| sr.apply(…) | 3 | sum 3 | s 3 |
| sr.agg(…) | | | | | sr.agg(…) | | | |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
``` ```
@ -3139,11 +3139,11 @@ y 2
| | 'rank' | ['rank'] | {'r': 'rank'} | | | 'rank' | ['rank'] | {'r': 'rank'} |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
| sr.apply(…) | | rank | | | sr.apply(…) | | rank | |
| sr.agg(…) | x 1 | x 1 | r x 1 |
| sr.trans(…) | y 2 | y 2 | y 2 |
| sr.agg(…) | x 1 | x 1 | r x 1 |
| sr.trans(…) | y 2 | y 2 | y 2 |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
``` ```
* **Last result has a hierarchical index. Use `'<Sr>[<key_1>, <key_2>]'` to get the value.**
* **Last result has a hierarchical index. Use `'<Sr>[key_1, key_2]'` to get its values.**
### DataFrame ### DataFrame
**Table with labeled rows and columns.** **Table with labeled rows and columns.**
@ -3248,9 +3248,9 @@ b 3 4
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
| | 'sum' | ['sum'] | {'x': 'sum'} | | | 'sum' | ['sum'] | {'x': 'sum'} |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
| df.apply(…) | | x y | |
| df.agg(…) | x 4 | sum 4 6 | x 4 |
| | y 6 | | |
| df.apply(…) | | x y | |
| df.agg(…) | x 4 | sum 4 6 | x 4 |
| | y 6 | | |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
``` ```
@ -3264,6 +3264,7 @@ b 3 4
| | | b 2 2 | | | | | b 2 2 | |
+-------------+-------------+-------------+---------------+ +-------------+-------------+-------------+---------------+
``` ```
* **Use `'<DF>[col_key_1, col_key_2][row_key]'` to get the fifth result's values.**
#### Encode, Decode: #### Encode, Decode:
```python ```python

17
index.html

@ -2668,7 +2668,7 @@ y <span class="hljs-number">2</span>
<pre><code class="python hljs">┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓ <pre><code class="python hljs">┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
┃ │ <span class="hljs-string">'sum'</span> │ [<span class="hljs-string">'sum'</span>] │ {<span class="hljs-string">'s'</span>: <span class="hljs-string">'sum'</span>} ┃ ┃ │ <span class="hljs-string">'sum'</span> │ [<span class="hljs-string">'sum'</span>] │ {<span class="hljs-string">'s'</span>: <span class="hljs-string">'sum'</span>} ┃
┠─────────────┼─────────────┼─────────────┼───────────────┨ ┠─────────────┼─────────────┼─────────────┼───────────────┨
┃ sr.apply(…) │ <span class="hljs-number">3</span> │ sum <span class="hljs-number">3</span> │ s <span class="hljs-number">3</span>
┃ sr.apply(…) │ <span class="hljs-number">3</span> │ sum <span class="hljs-number">3</span> │ s <span class="hljs-number">3</span>
┃ sr.agg(…) │ │ │ ┃ ┃ sr.agg(…) │ │ │ ┃
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
</code></pre> </code></pre>
@ -2676,12 +2676,12 @@ y <span class="hljs-number">2</span>
┃ │ <span class="hljs-string">'rank'</span> │ [<span class="hljs-string">'rank'</span>] │ {<span class="hljs-string">'r'</span>: <span class="hljs-string">'rank'</span>} ┃ ┃ │ <span class="hljs-string">'rank'</span> │ [<span class="hljs-string">'rank'</span>] │ {<span class="hljs-string">'r'</span>: <span class="hljs-string">'rank'</span>} ┃
┠─────────────┼─────────────┼─────────────┼───────────────┨ ┠─────────────┼─────────────┼─────────────┼───────────────┨
┃ sr.apply(…) │ │ rank │ ┃ ┃ sr.apply(…) │ │ rank │ ┃
┃ sr.agg(…) │ x <span class="hljs-number">1</span> │ x <span class="hljs-number">1</span> │ r x <span class="hljs-number">1</span>
┃ sr.trans(…) │ y <span class="hljs-number">2</span> │ y <span class="hljs-number">2</span> │ y <span class="hljs-number">2</span>
┃ sr.agg(…) │ x <span class="hljs-number">1</span> │ x <span class="hljs-number">1</span> │ r x <span class="hljs-number">1</span>
┃ sr.trans(…) │ y <span class="hljs-number">2</span> │ y <span class="hljs-number">2</span> │ y <span class="hljs-number">2</span>
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
</code></pre> </code></pre>
<ul> <ul>
<li><strong>Last result has a hierarchical index. Use <code class="python hljs"><span class="hljs-string">'&lt;Sr&gt;[&lt;key_1&gt;, &lt;key_2&gt;]'</span></code> to get the value.</strong></li>
<li><strong>Last result has a hierarchical index. Use <code class="python hljs"><span class="hljs-string">'&lt;Sr&gt;[key_1, key_2]'</span></code> to get its values.</strong></li>
</ul> </ul>
<div><h3 id="dataframe">DataFrame</h3><p><strong>Table with labeled rows and columns.</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>DataFrame([[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>]], index=[<span class="hljs-string">'a'</span>, <span class="hljs-string">'b'</span>], columns=[<span class="hljs-string">'x'</span>, <span class="hljs-string">'y'</span>]) <div><h3 id="dataframe">DataFrame</h3><p><strong>Table with labeled rows and columns.</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>DataFrame([[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>]], index=[<span class="hljs-string">'a'</span>, <span class="hljs-string">'b'</span>], columns=[<span class="hljs-string">'x'</span>, <span class="hljs-string">'y'</span>])
x y x y
@ -2766,9 +2766,9 @@ b <span class="hljs-number">3</span> <span class="hljs-number">4</span>
<pre><code class="python hljs">┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓ <pre><code class="python hljs">┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
┃ │ <span class="hljs-string">'sum'</span> │ [<span class="hljs-string">'sum'</span>] │ {<span class="hljs-string">'x'</span>: <span class="hljs-string">'sum'</span>} ┃ ┃ │ <span class="hljs-string">'sum'</span> │ [<span class="hljs-string">'sum'</span>] │ {<span class="hljs-string">'x'</span>: <span class="hljs-string">'sum'</span>} ┃
┠─────────────┼─────────────┼─────────────┼───────────────┨ ┠─────────────┼─────────────┼─────────────┼───────────────┨
┃ df.apply(…) │ │ x y │ ┃
┃ df.agg(…) │ x <span class="hljs-number">4</span> sum <span class="hljs-number">4</span> <span class="hljs-number">6</span> │ x <span class="hljs-number">4</span>
┃ │ y <span class="hljs-number">6</span> │ │ ┃
┃ df.apply(…) │ │ x y │ ┃
┃ df.agg(…) │ x <span class="hljs-number">4</span> │ sum <span class="hljs-number">4</span> <span class="hljs-number">6</span> │ x <span class="hljs-number">4</span>
┃ │ y <span class="hljs-number">6</span> │ │ ┃
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
</code></pre> </code></pre>
<pre><code class="python hljs">┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓ <pre><code class="python hljs">┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
@ -2780,6 +2780,9 @@ b <span class="hljs-number">3</span> <span class="hljs-number">4</span>
┃ │ │ b <span class="hljs-number">2</span> <span class="hljs-number">2</span> │ ┃ ┃ │ │ b <span class="hljs-number">2</span> <span class="hljs-number">2</span> │ ┃
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
</code></pre> </code></pre>
<ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'&lt;DF&gt;[col_key_1, col_key_2][row_key]'</span></code> to get the fifth result's values.</strong></li>
</ul>
<div><h4 id="encodedecode">Encode, Decode:</h4><pre><code class="python language-python hljs">&lt;DF&gt; = pd.read_json/html(<span class="hljs-string">'&lt;str/path/url&gt;'</span>) <div><h4 id="encodedecode">Encode, Decode:</h4><pre><code class="python language-python hljs">&lt;DF&gt; = pd.read_json/html(<span class="hljs-string">'&lt;str/path/url&gt;'</span>)
&lt;DF&gt; = pd.read_csv/pickle/excel(<span class="hljs-string">'&lt;path/url&gt;'</span>) &lt;DF&gt; = pd.read_csv/pickle/excel(<span class="hljs-string">'&lt;path/url&gt;'</span>)
&lt;DF&gt; = pd.read_sql(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;connection&gt;) &lt;DF&gt; = pd.read_sql(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;connection&gt;)

16
parse.js

@ -275,13 +275,13 @@ const DIAGRAM_12_B =
'┗━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━━━━┛\n'; '┗━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━━━━┛\n';
const DIAGRAM_13_A = const DIAGRAM_13_A =
'| sr.apply(…) | 3 | sum 3 | s 3 |';
'| sr.apply(…) | 3 | sum 3 | s 3 |';
const DIAGRAM_13_B = const DIAGRAM_13_B =
"┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" + "┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ ['sum'] │ {'s': 'sum'} ┃\n" + "┃ │ 'sum' │ ['sum'] │ {'s': 'sum'} ┃\n" +
"┠─────────────┼─────────────┼─────────────┼───────────────┨\n" + "┠─────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ sr.apply(…) │ 3 │ sum 3 │ s 3 ┃\n" +
"┃ sr.apply(…) │ 3 │ sum 3 │ s 3 ┃\n" +
"┃ sr.agg(…) │ │ │ ┃\n" + "┃ sr.agg(…) │ │ │ ┃\n" +
"┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; "┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
@ -293,8 +293,8 @@ const DIAGRAM_14_B =
"┃ │ 'rank' │ ['rank'] │ {'r': 'rank'} ┃\n" + "┃ │ 'rank' │ ['rank'] │ {'r': 'rank'} ┃\n" +
"┠─────────────┼─────────────┼─────────────┼───────────────┨\n" + "┠─────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ sr.apply(…) │ │ rank │ ┃\n" + "┃ sr.apply(…) │ │ rank │ ┃\n" +
"┃ sr.agg(…) │ x 1 │ x 1 │ r x 1 ┃\n" +
"┃ sr.trans(…) │ y 2 │ y 2 │ y 2 ┃\n" +
"┃ sr.agg(…) │ x 1 │ x 1 │ r x 1 ┃\n" +
"┃ sr.trans(…) │ y 2 │ y 2 │ y 2 ┃\n" +
"┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; "┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_15_A = const DIAGRAM_15_A =
@ -332,15 +332,15 @@ const DIAGRAM_15_B =
"┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"; "┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_16_A = const DIAGRAM_16_A =
'| df.apply(…) | | x y | |';
'| df.apply(…) | | x y | |';
const DIAGRAM_16_B = const DIAGRAM_16_B =
"┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" + "┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ ['sum'] │ {'x': 'sum'} ┃\n" + "┃ │ 'sum' │ ['sum'] │ {'x': 'sum'} ┃\n" +
"┠─────────────┼─────────────┼─────────────┼───────────────┨\n" + "┠─────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ df.apply(…) │ │ x y │ ┃\n" +
"┃ df.agg(…) │ x 4 sum 4 6 │ x 4 ┃\n" +
"┃ │ y 6 │ │ ┃\n" +
"┃ df.apply(…) │ │ x y │ ┃\n" +
"┃ df.agg(…) │ x 4 │ sum 4 6 │ x 4 ┃\n" +
"┃ │ y 6 │ │ ┃\n" +
"┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; "┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_17_A = const DIAGRAM_17_A =

Loading…
Cancel
Save