|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>March 3, 2022</aside> |
| 57 | + <aside>March 8, 2022</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
1319 | 1319 | <ul>
|
1320 | 1320 | <li><strong><code class="python hljs"><span class="hljs-string">'encoding=None'</span></code> means that the default encoding is used, which is platform dependent. Best practice is to use <code class="python hljs"><span class="hljs-string">'encoding="utf-8"'</span></code> whenever possible.</strong></li>
|
1321 | 1321 | <li><strong><code class="python hljs"><span class="hljs-string">'newline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
|
1322 |
| -<li><strong><code class="python hljs"><span class="hljs-string">'newline=""'</span></code> means no conversions take place, but input is still broken into chunks by readline() and readlines() on '\n', '\r' and '\r\n'.</strong></li> |
| 1322 | +<li><strong><code class="python hljs"><span class="hljs-string">'newline=""'</span></code> means no conversions take place, but input is still broken into chunks by readline() and readlines() on every '\n', '\r' and '\r\n'.</strong></li> |
1323 | 1323 | </ul>
|
1324 | 1324 | <div><h3 id="modes">Modes</h3><ul>
|
1325 | 1325 | <li><strong><code class="python hljs"><span class="hljs-string">'r'</span></code> - Read (default).</strong></li>
|
|
1577 | 1577 | </code></pre></div>
|
1578 | 1578 |
|
1579 | 1579 |
|
1580 |
| -<div><h3 id="example">Example</h3><p><strong>In this example values are not actually saved because <code class="python hljs"><span class="hljs-string">'conn.commit()'</span></code> is omitted!</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>conn = sqlite3.connect(<span class="hljs-string">'test.db'</span>) |
| 1580 | +<div><h3 id="example">Example</h3><p><strong>Values are not actually saved in this example because <code class="python hljs"><span class="hljs-string">'conn.commit()'</span></code> is omitted!</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>conn = sqlite3.connect(<span class="hljs-string">'test.db'</span>) |
1581 | 1581 | <span class="hljs-meta">>>> </span>conn.execute(<span class="hljs-string">'CREATE TABLE person (person_id INTEGER PRIMARY KEY, name, height)'</span>)
|
1582 | 1582 | <span class="hljs-meta">>>> </span>conn.execute(<span class="hljs-string">'INSERT INTO person VALUES (NULL, ?, ?)'</span>, (<span class="hljs-string">'Jean-Luc'</span>, <span class="hljs-number">187</span>)).lastrowid
|
1583 | 1583 | <span class="hljs-number">1</span>
|
|
2555 | 2555 | <Sr> = <Sr>.fillna(<el>) <span class="hljs-comment"># Or: <Sr>.agg/transform/map(lambda <el>: <el>)</span>
|
2556 | 2556 | </code></pre></div>
|
2557 | 2557 |
|
2558 |
| -<ul> |
2559 |
| -<li><strong>The way <code class="python hljs"><span class="hljs-string">'agg()'</span></code> and <code class="python hljs"><span class="hljs-string">'transform()'</span></code> find out whether the passed function accepts an element or the whole Series is by passing it a single value at first and if it raises an error, then they pass it the whole Series. <code class="python hljs"><span class="hljs-string">'agg()'</span></code> only accepts Attribute/Type/ValueError.</strong></li> |
2560 |
| -</ul> |
2561 | 2558 | <pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>sr = Series([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], index=[<span class="hljs-string">'x'</span>, <span class="hljs-string">'y'</span>])
|
2562 | 2559 | x <span class="hljs-number">1</span>
|
2563 | 2560 | y <span class="hljs-number">2</span>
|
|
2580 | 2577 | <ul>
|
2581 | 2578 | <li><strong>Last result has a hierarchical index. Use <code class="python hljs"><span class="hljs-string">'<Sr>[key_1, key_2]'</span></code> to get its values.</strong></li>
|
2582 | 2579 | </ul>
|
| 2580 | +<div><h4 id="seriesplot">Series — Plot:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt |
| 2581 | +<Sr>.plot.line/area/bar/pie/hist(); plt.show() |
| 2582 | +</code></pre></div> |
| 2583 | + |
2583 | 2584 | <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">>>> </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>])
|
2584 | 2585 | x y
|
2585 | 2586 | a <span class="hljs-number">1</span> <span class="hljs-number">2</span>
|
|
2884 | 2885 |
|
2885 | 2886 |
|
2886 | 2887 | <footer>
|
2887 |
| - <aside>March 3, 2022</aside> |
| 2888 | + <aside>March 8, 2022</aside> |
2888 | 2889 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2889 | 2890 | </footer>
|
2890 | 2891 |
|
|
0 commit comments