Browse Source

Pandas

pull/135/merge
Jure Šorn 1 month ago
parent
commit
dddae77ab7
3 changed files with 76 additions and 10 deletions
  1. 8
      README.md
  2. 12
      index.html
  3. 66
      parse.js

8
README.md

@ -3165,7 +3165,6 @@ Name: a, dtype: int64
```python
<S> = pd.Series(<list>) # Uses list's indices for 'index'.
<S> = pd.Series(<dict>) # Uses dictionary's keys for 'index'.
<S> = pd.concat(<coll_of_S>) # Also <S>.combine_first(<S>), <S>.update(<S>).
```
```python
@ -3186,8 +3185,9 @@ Name: a, dtype: int64
```
```python
<S> = <S>.value_counts(normalize=False) # Returns S of unique values and their counts.
<S> = <S>.str.strip/lower/contains/replace() # Processes strings. For dates see File Formats.
<S> = <S>.head/describe/copy/sort_values() # Also <S>.unique/value_counts/round/dropna().
<S> = <S>.str.strip/lower/contains/replace() # Also split().str[<int>] and split().explode().
<S> = <S>.dt.year/month/day/hour # Use pd.to_datetime(<S>) to get S of dates.
```
```python
@ -3222,7 +3222,7 @@ Name: a, dtype: int64
| | y 2.0 | y 2.0 | y 2.0 |
+--------------+-------------+-------------+---------------+
```
* **Methods ffill(), interpolate(), fillna() and dropna() accept `'inplace=True'`.**
* **Methods sort_values(), dropna(), ffill(), interpolate() and fillna() accept `'inplace=True'`.**
* **Agg() and transform() pass a Series to a function if it raises Type/Val/AttrError on a scalar.**
* **Last result has a multi-index. Use `'<S>[key_1, key_2]'` to get its values.**

12
index.html

@ -55,7 +55,7 @@
<body>
<header>
<aside>January 11, 2025</aside>
<aside>January 24, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2582,7 +2582,6 @@ Name: a, dtype: int64
<pre><code class="python language-python hljs">&lt;S&gt; = pd.Series(&lt;list&gt;) <span class="hljs-comment"># Uses list's indices for 'index'.</span>
&lt;S&gt; = pd.Series(&lt;dict&gt;) <span class="hljs-comment"># Uses dictionary's keys for 'index'.</span>
&lt;S&gt; = pd.concat(&lt;coll_of_S&gt;) <span class="hljs-comment"># Also &lt;S&gt;.combine_first(&lt;S&gt;), &lt;S&gt;.update(&lt;S&gt;).</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;el&gt; = &lt;S&gt;.loc[key] <span class="hljs-comment"># Or: &lt;S&gt;.iloc[i]</span>
&lt;S&gt; = &lt;S&gt;.loc[coll_of_keys] <span class="hljs-comment"># Or: &lt;S&gt;.iloc[coll_of_i]</span>
@ -2595,8 +2594,9 @@ Name: a, dtype: int64
<pre><code class="python language-python hljs">&lt;S&gt; = &lt;S&gt; &gt; &lt;el/S&gt; <span class="hljs-comment"># Returns S of bools. For logic use &amp;, |, ~.</span>
&lt;S&gt; = &lt;S&gt; + &lt;el/S&gt; <span class="hljs-comment"># Items with non-matching keys get value NaN.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;S&gt; = &lt;S&gt;.value_counts(normalize=<span class="hljs-keyword">False</span>) <span class="hljs-comment"># Returns S of unique values and their counts.</span>
&lt;S&gt; = &lt;S&gt;.str.strip/lower/contains/replace() <span class="hljs-comment"># Processes strings. For dates see File Formats.</span>
<pre><code class="python language-python hljs">&lt;S&gt; = &lt;S&gt;.head/describe/copy/sort_values() <span class="hljs-comment"># Also &lt;S&gt;.unique/value_counts/round/dropna().</span>
&lt;S&gt; = &lt;S&gt;.str.strip/lower/contains/replace() <span class="hljs-comment"># Also split().str[&lt;int&gt;] and split().explode().</span>
&lt;S&gt; = &lt;S&gt;.dt.year/month/day/hour <span class="hljs-comment"># Use pd.to_datetime(&lt;S&gt;) to get S of dates.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;S&gt;.plot.line/area/bar/pie/hist() <span class="hljs-comment"># Generates a plot. `plt.show()` displays it.</span>
</code></pre>
@ -2627,7 +2627,7 @@ Name: a, dtype: int64
</code></pre>
<ul>
<li><strong>Methods ffill(), interpolate(), fillna() and dropna() accept <code class="python hljs"><span class="hljs-string">'inplace=True'</span></code>.</strong></li>
<li><strong>Methods sort_values(), dropna(), ffill(), interpolate() and fillna() accept <code class="python hljs"><span class="hljs-string">'inplace=True'</span></code>.</strong></li>
<li><strong>Agg() and transform() pass a Series to a function if it raises Type/Val/AttrError on a scalar.</strong></li>
<li><strong>Last result has a multi-index. Use <code class="python hljs"><span class="hljs-string">'&lt;S&gt;[key_1, key_2]'</span></code> to get its values.</strong></li>
</ul>
@ -2932,7 +2932,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
<footer>
<aside>January 11, 2025</aside>
<aside>January 24, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

66
parse.js

@ -591,6 +591,72 @@ const DIAGRAM_13_B =
"┃ │ y 2.0 │ y 2.0 │ y 2.0 ┃\n" +
"┗━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_13_BB =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'mean' │ ['mean'] │ {'m': 'mean'} ┃\n" +
"┠────────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ s.apply/agg(…) │ 1.5 │ mean 1.5 │ m 1.5 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n" +
"\n" +
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'rank' │ ['rank'] │ {'r': 'rank'} ┃\n" +
"┠────────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ s.apply/agg(…) │ │ rank │ ┃\n" +
"┃ │ x 1.0 │ x 1.0 │ r x 1.0 ┃\n" +
"┃ │ y 2.0 │ y 2.0 │ y 2.0 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_13_XXX =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ ['sum', 'max'] │ 'rank' │ ['rank', 'diff'] ┃\n" +
"┠────────────────┼───────────┼────────────────┼───────────┼──────────────────┨\n" +
"┃ s.apply/agg(…) │ 3 │ sum 3 │ x 1.0 │ rank diff ┃\n" +
"┃ │ │ max 2 │ y 2.0 │ x 1.0 NaN ┃\n" +
"┃ │ │ Name: a │ Name: a │ y 2.0 1.0 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_13_XX =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ 'rank' │ ['sum', 'max'] ┃\n" +
"┠────────────────┼───────────┼───────────┼────────────────┨\n" +
"┃ s.apply/agg(…) │ 3 │ x 1.0 │ sum 3 ┃\n" +
"┃ │ │ y 2.0 │ max 2 ┃\n" +
"┃ │ │ Name: a │ Name: a ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_13_X =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ 'rank' │ ['sum', 'max'] │ ['rank', 'diff'] ┃\n" +
"┠────────────────┼───────────┼───────────┼────────────────┼──────────────────┨\n" +
"┃ s.apply/agg(…) │ 3 │ x 1.0 │ sum 3 │ rank diff ┃\n" +
"┃ │ │ y 2.0 │ max 2 │ x 1.0 NaN ┃\n" +
"┃ │ │ Name: a │ Name: a │ y 2.0 1.0 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_13_Y =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ 'rank' │ ['sum'] │ ['rank'] ┃\n" +
"┠────────────────┼───────────┼───────────┼───────────┼───────────┨\n" +
"┃ s.apply/agg(…) │ 3 │ x 1.0 │ sum 3 │ rank ┃\n" +
"┃ │ │ y 2.0 │ Name: a │ x 1.0 ┃\n" +
"┃ │ │ Name: a │ │ y 2.0 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┛\n";
const DIAGRAM_13_BBB =
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'sum' │ ['sum'] │ {'s': 'sum'} ┃\n" +
"┠────────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ s.apply/agg(…) │ 3 │ sum 3 │ s 3 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n" +
"\n" +
"┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓\n" +
"┃ │ 'rank' │ ['rank'] │ {'r': 'rank'} ┃\n" +
"┠────────────────┼─────────────┼─────────────┼───────────────┨\n" +
"┃ s.apply/agg(…) │ │ rank │ ┃\n" +
"┃ │ x 1.0 │ x 1.0 │ r x 1.0 ┃\n" +
"┃ │ y 2.0 │ y 2.0 │ y 2.0 ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_14_A =
"| | 'rank' | ['rank'] | {'r': 'rank'} |";

Loading…
Cancel
Save