Browse Source

Pandas

pull/167/head
Jure Šorn 1 year ago
parent
commit
a238e85661
2 changed files with 8 additions and 8 deletions
  1. 6
      README.md
  2. 10
      index.html

6
README.md

@ -1156,7 +1156,7 @@ class MySortable:
### Iterator ### Iterator
* **Any object that has methods next() and iter() is an iterator.** * **Any object that has methods next() and iter() is an iterator.**
* **Next() should return next item or raise StopIteration.**
* **Next() should return next item or raise StopIteration exception.**
* **Iter() should return 'self'.** * **Iter() should return 'self'.**
```python ```python
class Counter: class Counter:
@ -3341,7 +3341,7 @@ plt.show() # Displays the plot. Also plt.sav
```python ```python
<DF> = pd.read_json/html('<str/path/url>') # Run `$ pip3 install beautifulsoup4 lxml`. <DF> = pd.read_json/html('<str/path/url>') # Run `$ pip3 install beautifulsoup4 lxml`.
<DF> = pd.read_csv/pickle/excel('<path/url>') # Use `sheet_name=None` to get all Excel sheets. <DF> = pd.read_csv/pickle/excel('<path/url>') # Use `sheet_name=None` to get all Excel sheets.
<DF> = pd.read_sql('<table/query>', <conn.>) # Accepts SQLite3 or SQLAlchemy connection.
<DF> = pd.read_sql('<table/query>', <conn.>) # SQLite3/SQLAlchemy connection (see #SQLite).
<DF> = pd.read_clipboard() # Reads a copied table from the clipboard. <DF> = pd.read_clipboard() # Reads a copied table from the clipboard.
``` ```
@ -3349,7 +3349,7 @@ plt.show() # Displays the plot. Also plt.sav
<dict> = <DF>.to_dict(['d/l/s/…']) # Returns columns as dicts, lists or series. <dict> = <DF>.to_dict(['d/l/s/…']) # Returns columns as dicts, lists or series.
<str> = <DF>.to_json/html/csv([<path>]) # Also to_markdown/latex([<path>]). <str> = <DF>.to_json/html/csv([<path>]) # Also to_markdown/latex([<path>]).
<DF>.to_pickle/excel(<path>) # Run `$ pip3 install "pandas[excel]" odfpy`. <DF>.to_pickle/excel(<path>) # Run `$ pip3 install "pandas[excel]" odfpy`.
<DF>.to_sql('<table_name>', <connection>) # Accepts SQLite3 or SQLAlchemy connection.
<DF>.to_sql('<table_name>', <connection>) # Also `if_exists='fail/replace/append'`.
``` ```
### GroupBy ### GroupBy

10
index.html

@ -54,7 +54,7 @@
<body> <body>
<header> <header>
<aside>September 11, 2023</aside>
<aside>September 15, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header> </header>
@ -979,7 +979,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<div><h3 id="iterator-1">Iterator</h3><ul> <div><h3 id="iterator-1">Iterator</h3><ul>
<li><strong>Any object that has methods next() and iter() is an iterator.</strong></li> <li><strong>Any object that has methods next() and iter() is an iterator.</strong></li>
<li><strong>Next() should return next item or raise StopIteration.</strong></li>
<li><strong>Next() should return next item or raise StopIteration exception.</strong></li>
<li><strong>Iter() should return 'self'.</strong></li> <li><strong>Iter() should return 'self'.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span>:</span> </ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self)</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self)</span>:</span>
@ -2731,13 +2731,13 @@ plt.show() <span class="hljs-comment"># Disp
<pre><code class="python language-python hljs">&lt;DF&gt; = pd.read_json/html(<span class="hljs-string">'&lt;str/path/url&gt;'</span>) <span class="hljs-comment"># Run `$ pip3 install beautifulsoup4 lxml`.</span> <pre><code class="python language-python hljs">&lt;DF&gt; = pd.read_json/html(<span class="hljs-string">'&lt;str/path/url&gt;'</span>) <span class="hljs-comment"># Run `$ pip3 install beautifulsoup4 lxml`.</span>
&lt;DF&gt; = pd.read_csv/pickle/excel(<span class="hljs-string">'&lt;path/url&gt;'</span>) <span class="hljs-comment"># Use `sheet_name=None` to get all Excel sheets.</span> &lt;DF&gt; = pd.read_csv/pickle/excel(<span class="hljs-string">'&lt;path/url&gt;'</span>) <span class="hljs-comment"># Use `sheet_name=None` to get all Excel sheets.</span>
&lt;DF&gt; = pd.read_sql(<span class="hljs-string">'&lt;table/query&gt;'</span>, &lt;conn.&gt;) <span class="hljs-comment"># Accepts SQLite3 or SQLAlchemy connection.</span>
&lt;DF&gt; = pd.read_sql(<span class="hljs-string">'&lt;table/query&gt;'</span>, &lt;conn.&gt;) <span class="hljs-comment"># SQLite3/SQLAlchemy connection (see #SQLite).</span>
&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 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 "pandas[excel]" odfpy`.</span> &lt;DF&gt;.to_pickle/excel(&lt;path&gt;) <span class="hljs-comment"># Run `$ pip3 install "pandas[excel]" odfpy`.</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"># Also `if_exists='fail/replace/append'`.</span>
</code></pre> </code></pre>
<div><h3 id="groupby">GroupBy</h3><p><strong>Object that groups together rows of a dataframe based on the value of the passed column.</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>df = pd.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>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">6</span>]], list(<span class="hljs-string">'abc'</span>), list(<span class="hljs-string">'xyz'</span>)) <div><h3 id="groupby">GroupBy</h3><p><strong>Object that groups together rows of a dataframe based on the value of the passed column.</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>df = pd.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>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">6</span>]], list(<span class="hljs-string">'abc'</span>), list(<span class="hljs-string">'xyz'</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>df.groupby(<span class="hljs-string">'z'</span>).get_group(<span class="hljs-number">6</span>) <span class="hljs-meta">&gt;&gt;&gt; </span>df.groupby(<span class="hljs-string">'z'</span>).get_group(<span class="hljs-number">6</span>)
@ -2928,7 +2928,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the activ
<footer> <footer>
<aside>September 11, 2023</aside>
<aside>September 15, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer> </footer>

Loading…
Cancel
Save