Browse Source

Pandas

pull/152/head
Jure Šorn 2 years ago
parent
commit
6b87a0c79a
3 changed files with 22 additions and 19 deletions
  1. 12
      README.md
  2. 14
      index.html
  3. 15
      parse.js

12
README.md

@ -3257,12 +3257,12 @@ c 6 7
+------------------------+---------------+------------+------------+--------------------------+ +------------------------+---------------+------------+------------+--------------------------+
| | 'outer' | 'inner' | 'left' | Description | | | 'outer' | 'inner' | 'left' | Description |
+------------------------+---------------+------------+------------+--------------------------+ +------------------------+---------------+------------+------------+--------------------------+
| l.merge(r, on='y', | x y z | x y z | x y z | Joins/merges on column. |
| how=…) | 0 1 2 . | 3 4 5 | 1 2 . | Also accepts left_on and |
| | 1 3 4 5 | | 3 4 5 | right_on parameters. |
| l.merge(r, on='y', | x y z | x y z | x y z | Merges on column if 'on' |
| how=…) | 0 1 2 . | 3 4 5 | 1 2 . | or 'left/right_on' are |
| | 1 3 4 5 | | 3 4 5 | set, else on shared cols.|
| | 2 . 6 7 | | | Uses 'inner' by default. | | | 2 . 6 7 | | | Uses 'inner' by default. |
+------------------------+---------------+------------+------------+--------------------------+ +------------------------+---------------+------------+------------+--------------------------+
| l.join(r, lsuffix='l', | x yl yr z | | x yl yr z | Joins/merges on row keys.|
| l.join(r, lsuffix='l', | x yl yr z | | x yl yr z | Merges on row keys. |
| rsuffix='r', | a 1 2 . . | x yl yr z | 1 2 . . | Uses 'left' by default. | | rsuffix='r', | a 1 2 . . | x yl yr z | 1 2 . . | Uses 'left' by default. |
| how=…) | b 3 4 4 5 | 3 4 4 5 | 3 4 4 5 | If r is a Series, it is | | how=…) | b 3 4 4 5 | 3 4 4 5 | 3 4 4 5 | If r is a Series, it is |
| | c . . 6 7 | | | treated as a column. | | | c . . 6 7 | | | treated as a column. |
@ -3270,8 +3270,8 @@ c 6 7
| pd.concat([l, r], | x y z | y | | Adds rows at the bottom. | | pd.concat([l, r], | x y z | y | | Adds rows at the bottom. |
| axis=0, | a 1 2 . | 2 | | Uses 'outer' by default. | | axis=0, | a 1 2 . | 2 | | Uses 'outer' by default. |
| join=…) | b 3 4 . | 4 | | A Series is treated as a | | join=…) | b 3 4 . | 4 | | A Series is treated as a |
| | b . 4 5 | 4 | | column. Use l.append(sr) |
| | c . 6 7 | 6 | | to add a row instead. |
| | b . 4 5 | 4 | | column. To add a row use |
| | c . 6 7 | 6 | | pd.concat([l, DF([sr])]).|
+------------------------+---------------+------------+------------+--------------------------+ +------------------------+---------------+------------+------------+--------------------------+
| pd.concat([l, r], | x y y z | | | Adds columns at the | | pd.concat([l, r], | x y y z | | | Adds columns at the |
| axis=1, | a 1 2 . . | x y y z | | right end. Uses 'outer' | | axis=1, | a 1 2 . . | x y y z | | right end. Uses 'outer' |

14
index.html

@ -2654,12 +2654,12 @@ c <span class="hljs-number">6</span> <span class="hljs-number">7</span>
<pre><code class="python hljs">┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓ <pre><code class="python hljs">┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ │ <span class="hljs-string">'outer'</span><span class="hljs-string">'inner'</span><span class="hljs-string">'left'</span> │ Description ┃ ┃ │ <span class="hljs-string">'outer'</span><span class="hljs-string">'inner'</span><span class="hljs-string">'left'</span> │ Description ┃
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨ ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
┃ l.merge(r, on=<span class="hljs-string">'y'</span>, │ x y z │ x y z │ x y z │ Joins/merges on column.
┃ how=…) │ <span class="hljs-number">0</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ Also accepts left_on and
┃ │ <span class="hljs-number">1</span> <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span> │ │ <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span>right_on parameters.
┃ l.merge(r, on=<span class="hljs-string">'y'</span>, │ x y z │ x y z │ x y z │ Merges on column if <span class="hljs-string">'on'</span>
┃ how=…) │ <span class="hljs-number">0</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ or <span class="hljs-string">'left/right_on'</span> are
┃ │ <span class="hljs-number">1</span> <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span> │ │ <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span>set, else on shared cols.
┃ │ <span class="hljs-number">2</span> . <span class="hljs-number">6</span> <span class="hljs-number">7</span> │ │ │ Uses <span class="hljs-string">'inner'</span> by default. ┃ ┃ │ <span class="hljs-number">2</span> . <span class="hljs-number">6</span> <span class="hljs-number">7</span> │ │ │ Uses <span class="hljs-string">'inner'</span> by default. ┃
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨ ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
┃ l.join(r, lsuffix=<span class="hljs-string">'l'</span>, │ x yl yr z │ │ x yl yr z │ Joins/merges on row keys.
┃ l.join(r, lsuffix=<span class="hljs-string">'l'</span>, │ x yl yr z │ │ x yl yr z │ Merges on row keys.
┃ rsuffix=<span class="hljs-string">'r'</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . . │ x yl yr z │ <span class="hljs-number">1</span> <span class="hljs-number">2</span> . . │ Uses <span class="hljs-string">'left'</span> by default. ┃ ┃ rsuffix=<span class="hljs-string">'r'</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . . │ x yl yr z │ <span class="hljs-number">1</span> <span class="hljs-number">2</span> . . │ Uses <span class="hljs-string">'left'</span> by default. ┃
┃ how=…) │ b <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span> │ If r is a Series, it is ┃ ┃ how=…) │ b <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span> │ If r is a Series, it is ┃
┃ │ c . . <span class="hljs-number">6</span> <span class="hljs-number">7</span> │ │ │ treated as a column. ┃ ┃ │ c . . <span class="hljs-number">6</span> <span class="hljs-number">7</span> │ │ │ treated as a column. ┃
@ -2667,8 +2667,8 @@ c <span class="hljs-number">6</span> <span class="hljs-number">7</span>
┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃ ┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃
┃ axis=<span class="hljs-number">0</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ <span class="hljs-number">2</span> │ │ Uses <span class="hljs-string">'outer'</span> by default. ┃ ┃ axis=<span class="hljs-number">0</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ <span class="hljs-number">2</span> │ │ Uses <span class="hljs-string">'outer'</span> by default. ┃
┃ join=…) │ b <span class="hljs-number">3</span> <span class="hljs-number">4</span> . │ <span class="hljs-number">4</span> │ │ A Series is treated as a ┃ ┃ join=…) │ b <span class="hljs-number">3</span> <span class="hljs-number">4</span> . │ <span class="hljs-number">4</span> │ │ A Series is treated as a ┃
┃ │ b . <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">4</span> │ │ column. Use l.append(sr)
┃ │ c . <span class="hljs-number">6</span> <span class="hljs-number">7</span><span class="hljs-number">6</span> │ │ to add a row instead.
┃ │ b . <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">4</span> │ │ column. To add a row use
┃ │ c . <span class="hljs-number">6</span> <span class="hljs-number">7</span><span class="hljs-number">6</span> │ │ pd.concat([l, DF([sr])]).
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨ ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃ ┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃
┃ axis=<span class="hljs-number">1</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . . │ x y y z │ │ right end. Uses <span class="hljs-string">'outer'</span> ┃ axis=<span class="hljs-number">1</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . . │ x y y z │ │ right end. Uses <span class="hljs-string">'outer'</span>
@ -2725,7 +2725,7 @@ plt.show() <span class="hljs-comment"># Disp
&lt;DF&gt; = pd.read_clipboard() <span class="hljs-comment"># Reads a copied table from the clipboard.</span> &lt;DF&gt; = pd.read_clipboard() <span class="hljs-comment"># Reads a copied table from the clipboard.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;dict&gt; = &lt;DF&gt;.to_dict([<span class="hljs-string">'d/l/s/…'</span>]) <span class="hljs-comment"># Returns columns as dicts, lists or series.</span> <pre><code class="python language-python hljs">&lt;dict&gt; = &lt;DF&gt;.to_dict([<span class="hljs-string">'d/l/s/…'</span>]) <span class="hljs-comment"># Returns columns as dicts, lists or series.</span>
&lt;str&gt; = &lt;DF&gt;.to_json/html/csv([&lt;path&gt;]) <span class="hljs-comment"># Also &lt;DF&gt;.to_markdown/latex([&lt;path&gt;]).</span>
&lt;str&gt; = &lt;DF&gt;.to_json/html/csv([&lt;path&gt;]) <span class="hljs-comment"># Also to_markdown/latex([&lt;path&gt;]).</span>
&lt;DF&gt;.to_pickle/excel(&lt;path&gt;) <span class="hljs-comment"># Run `$ pip3 install openpyxl` for xlsx files.</span> &lt;DF&gt;.to_pickle/excel(&lt;path&gt;) <span class="hljs-comment"># Run `$ pip3 install openpyxl` for xlsx files.</span>
&lt;DF&gt;.to_sql(<span class="hljs-string">'&lt;table_name&gt;'</span>, &lt;connection&gt;) <span class="hljs-comment"># Accepts SQLite3 or SQLAlchemy connection.</span> &lt;DF&gt;.to_sql(<span class="hljs-string">'&lt;table_name&gt;'</span>, &lt;connection&gt;) <span class="hljs-comment"># Accepts SQLite3 or SQLAlchemy connection.</span>
</code></pre> </code></pre>

15
parse.js

@ -511,12 +511,12 @@ const DIAGRAM_15_B =
"┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" + "┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'outer' │ 'inner' │ 'left' │ Description ┃\n" + "┃ │ 'outer' │ 'inner' │ 'left' │ Description ┃\n" +
"┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" +
"┃ l.merge(r, on='y', │ x y z │ x y z │ x y z │ Joins/merges on column. ┃\n" +
"┃ how=…) │ 0 1 2 . │ 3 4 5 │ 1 2 . │ Also accepts left_on and ┃\n" +
"┃ │ 1 3 4 5 │ │ 3 4 5 │ right_on parameters. ┃\n" +
"┃ l.merge(r, on='y', │ x y z │ x y z │ x y z │ Merges on column if 'on' ┃\n" +
"┃ how=…) │ 0 1 2 . │ 3 4 5 │ 1 2 . │ or 'left/right_on' are ┃\n" +
"┃ │ 1 3 4 5 │ │ 3 4 5 │ set, else on shared cols.┃\n" +
"┃ │ 2 . 6 7 │ │ │ Uses 'inner' by default. ┃\n" + "┃ │ 2 . 6 7 │ │ │ Uses 'inner' by default. ┃\n" +
"┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" +
"┃ l.join(r, lsuffix='l', │ x yl yr z │ │ x yl yr z │ Joins/merges on row keys.┃\n" +
"┃ l.join(r, lsuffix='l', │ x yl yr z │ │ x yl yr z │ Merges on row keys. ┃\n" +
"┃ rsuffix='r', │ a 1 2 . . │ x yl yr z │ 1 2 . . │ Uses 'left' by default. ┃\n" + "┃ rsuffix='r', │ a 1 2 . . │ x yl yr z │ 1 2 . . │ Uses 'left' by default. ┃\n" +
"┃ how=…) │ b 3 4 4 5 │ 3 4 4 5 │ 3 4 4 5 │ If r is a Series, it is ┃\n" + "┃ how=…) │ b 3 4 4 5 │ 3 4 4 5 │ 3 4 4 5 │ If r is a Series, it is ┃\n" +
"┃ │ c . . 6 7 │ │ │ treated as a column. ┃\n" + "┃ │ c . . 6 7 │ │ │ treated as a column. ┃\n" +
@ -524,8 +524,8 @@ const DIAGRAM_15_B =
"┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃\n" + "┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃\n" +
"┃ axis=0, │ a 1 2 . │ 2 │ │ Uses 'outer' by default. ┃\n" + "┃ axis=0, │ a 1 2 . │ 2 │ │ Uses 'outer' by default. ┃\n" +
"┃ join=…) │ b 3 4 . │ 4 │ │ A Series is treated as a ┃\n" + "┃ join=…) │ b 3 4 . │ 4 │ │ A Series is treated as a ┃\n" +
"┃ │ b . 4 5 │ 4 │ │ column. Use l.append(sr) ┃\n" +
"┃ │ c . 6 7 │ 6 │ │ to add a row instead. ┃\n" +
"┃ │ b . 4 5 │ 4 │ │ column. To add a row use ┃\n" +
"┃ │ c . 6 7 │ 6 │ │ pd.concat([l, DF([sr])]).┃\n" +
"┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" +
"┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃\n" + "┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃\n" +
"┃ axis=1, │ a 1 2 . . │ x y y z │ │ right end. Uses 'outer' ┃\n" + "┃ axis=1, │ a 1 2 . . │ x y y z │ │ right end. Uses 'outer' ┃\n" +
@ -798,6 +798,9 @@ function fixPandasDiagram() {
$(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(and)").after("and"); $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(and)").after("and");
$(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(as)").after("as"); $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(as)").after("as");
$(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(is)").after("is"); $(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(is)").after("is");
$(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(if)").after("if");
$(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(or)").after("or");
$(`code:contains(${diagram_15})`).find(".hljs-keyword:contains(else)").after("else");
$(`code:contains(${diagram_15})`).find(".hljs-keyword").remove(); $(`code:contains(${diagram_15})`).find(".hljs-keyword").remove();
} }

Loading…
Cancel
Save