|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>October 11, 2023</aside> |
| 57 | + <aside>October 16, 2023</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
1553 | 1553 | <span class="hljs-keyword">return</span> list(csv.reader(file, dialect, **params))
|
1554 | 1554 | </code></pre></div>
|
1555 | 1555 |
|
1556 |
| -<div><h3 id="writerowstocsvfile">Write Rows to CSV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_csv_file</span><span class="hljs-params">(filename, rows, dialect=<span class="hljs-string">'excel'</span>, **params)</span>:</span> |
1557 |
| - <span class="hljs-keyword">with</span> open(filename, <span class="hljs-string">'w'</span>, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file: |
| 1556 | +<div><h3 id="writerowstocsvfile">Write Rows to CSV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_csv_file</span><span class="hljs-params">(filename, rows, mode=<span class="hljs-string">'w'</span>, dialect=<span class="hljs-string">'excel'</span>, **params)</span>:</span> |
| 1557 | + <span class="hljs-keyword">with</span> open(filename, mode, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file: |
1558 | 1558 | writer = csv.writer(file, dialect, **params)
|
1559 | 1559 | writer.writerows(rows)
|
1560 | 1560 | </code></pre></div>
|
@@ -1979,7 +1979,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
1979 | 1979 | </code></pre></div></div>
|
1980 | 1980 |
|
1981 | 1981 |
|
1982 |
| -<div><h2 id="curses"><a href="#curses" name="curses">#</a>Curses</h2><div><h4 id="runsabasicfileexplorerintheterminal">Runs a basic file explorer in the terminal:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> curses, os |
| 1982 | +<div><h2 id="curses"><a href="#curses" name="curses">#</a>Curses</h2><div><h4 id="runsabasicfileexplorerintheconsole">Runs a basic file explorer in the console:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> curses, os |
1983 | 1983 | <span class="hljs-keyword">from</span> curses <span class="hljs-keyword">import</span> A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER
|
1984 | 1984 |
|
1985 | 1985 | <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">(screen)</span>:</span>
|
@@ -2141,7 +2141,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2141 | 2141 | <div><h3 id="callandflamegraphs">Call and Flame Graphs</h3><pre><code class="text language-text">$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
|
2142 | 2142 | $ tail -n 4 test.py > test.py
|
2143 | 2143 | $ python3 -m cProfile -o test.prof test.py
|
2144 |
| -$ gprof2dot -f pstats test.prof | dot -Tpng -o test.png; xdg-open/open test.png |
| 2144 | +$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png |
2145 | 2145 | $ snakeviz test.prof
|
2146 | 2146 | </code></pre></div>
|
2147 | 2147 |
|
@@ -2262,7 +2262,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2262 | 2262 | <pre><code class="python language-python hljs"><Image> = <Image>.filter(<Filter>) <span class="hljs-comment"># `<Filter> = ImageFilter.<name>([<args>])`</span>
|
2263 | 2263 | <Image> = <Enhance>.enhance(<float>) <span class="hljs-comment"># `<Enhance> = ImageEnhance.<name>(<Image>)`</span>
|
2264 | 2264 | </code></pre>
|
2265 |
| -<pre><code class="python language-python hljs"><array> = np.array(<Image>) <span class="hljs-comment"># Creates NumPy array from the image.</span> |
| 2265 | +<pre><code class="python language-python hljs"><array> = np.array(<Image>) <span class="hljs-comment"># Creates a NumPy array from the image.</span> |
2266 | 2266 | <Image> = Image.fromarray(np.uint8(<array>)) <span class="hljs-comment"># Use <array>.clip(0, 255) to clip values.</span>
|
2267 | 2267 | </code></pre>
|
2268 | 2268 | <div><h3 id="modes-1">Modes</h3><ul>
|
@@ -2638,7 +2638,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2638 | 2638 | </code></pre>
|
2639 | 2639 | <pre><code class="python language-python hljs"><Sr/DF> = <DF>[column_key/s] <span class="hljs-comment"># Or: <DF>.column_key</span>
|
2640 | 2640 | <DF> = <DF>[row_bools] <span class="hljs-comment"># Keeps rows as specified by bools.</span>
|
2641 |
| -<DF> = <DF>[<DF_of_bools>] <span class="hljs-comment"># Assigns NaN to values that are False in bools.</span> |
| 2641 | +<DF> = <DF>[<DF_of_bools>] <span class="hljs-comment"># Assigns NaN to items that are False in bools.</span> |
2642 | 2642 | </code></pre>
|
2643 | 2643 | <pre><code class="python language-python hljs"><DF> = <DF> > <el/Sr/DF> <span class="hljs-comment"># Returns DF of bools. Sr is treated as a row.</span>
|
2644 | 2644 | <DF> = <DF> + <el/Sr/DF> <span class="hljs-comment"># Items with non-matching keys get value NaN.</span>
|
@@ -2925,7 +2925,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2925 | 2925 |
|
2926 | 2926 |
|
2927 | 2927 | <footer>
|
2928 |
| - <aside>October 11, 2023</aside> |
| 2928 | + <aside>October 16, 2023</aside> |
2929 | 2929 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2930 | 2930 | </footer>
|
2931 | 2931 |
|
|
0 commit comments