|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>April 9, 2023</aside> |
| 57 | + <aside>April 11, 2023</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
1439 | 1439 |
|
1440 | 1440 | <pre><code class="python language-python hljs">os.chdir(<path>) <span class="hljs-comment"># Changes the current working directory.</span>
|
1441 | 1441 | os.mkdir(<path>, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory. Permissions are in octal.</span>
|
1442 |
| -os.makedirs(<path>, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates all path's dirs. Also: `exist_ok=False`.</span> |
| 1442 | +os.makedirs(<path>, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates all path's dirs. Also `exist_ok=False`.</span> |
1443 | 1443 | </code></pre>
|
1444 | 1444 | <pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file. 'to' can exist or be a dir.</span>
|
1445 | 1445 | shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory. 'to' must not exist.</span>
|
@@ -2048,7 +2048,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2048 | 2048 | <span class="hljs-meta">>>> </span>logger.addHandler(handler)
|
2049 | 2049 | <span class="hljs-meta">>>> </span>logger.critical(<span class="hljs-string">'Running out of disk space.'</span>)
|
2050 | 2050 | CRITICAL:my_module:Running out of disk space.
|
2051 |
| -<span class="hljs-meta">>>> </span>open(<span class="hljs-string">'test.log'</span>).read() |
| 2051 | +<span class="hljs-meta">>>> </span>print(open(<span class="hljs-string">'test.log'</span>).read()) |
2052 | 2052 | 2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
|
2053 | 2053 | </code></pre></div>
|
2054 | 2054 |
|
@@ -2463,13 +2463,13 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2463 | 2463 | <div><h3 id="surface">Surface</h3><p><strong>Object for representing images.</strong></p><pre><code class="python language-python hljs"><Surf> = pg.display.set_mode((width, height)) <span class="hljs-comment"># Opens new window and returns its surface.</span>
|
2464 | 2464 | <Surf> = pg.Surface((width, height)) <span class="hljs-comment"># New RGB surface. RGBA if `flags=pg.SRCALPHA`.</span>
|
2465 | 2465 | <Surf> = pg.image.load(<path/file>) <span class="hljs-comment"># Loads the image. Format depends on source.</span>
|
2466 |
| -<Surf> = pg.surfarray.make_surface(<np_array>) <span class="hljs-comment"># Also `<array> = surfarray.pixels3d(<Surf>)`.</span> |
| 2466 | +<Surf> = pg.surfarray.make_surface(<np_array>) <span class="hljs-comment"># Also `<np_arr> = surfarray.pixels3d(<Surf>)`.</span> |
2467 | 2467 | <Surf> = <Surf>.subsurface(<Rect>) <span class="hljs-comment"># Returns a subsurface.</span>
|
2468 | 2468 | </code></pre></div>
|
2469 | 2469 |
|
2470 | 2470 |
|
2471 | 2471 | <pre><code class="python language-python hljs"><Surf>.fill(color) <span class="hljs-comment"># Tuple, Color('#rrggbb[aa]') or Color(<name>).</span>
|
2472 |
| -<Surf>.set_at((x, y), color) <span class="hljs-comment"># Updates pixel.</span> |
| 2472 | +<Surf>.set_at((x, y), color) <span class="hljs-comment"># Updates pixel. Also <Surf>.get_at((x, y)).</span> |
2473 | 2473 | <Surf>.blit(<Surf>, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span>
|
2474 | 2474 | </code></pre>
|
2475 | 2475 | <pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> pygame.transform <span class="hljs-keyword">import</span> scale, ...
|
@@ -2740,7 +2740,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2740 | 2740 | </code></pre>
|
2741 | 2741 | <pre><code class="python language-python hljs"><dict> = <DF>.to_dict([<span class="hljs-string">'d/l/s/…'</span>]) <span class="hljs-comment"># Returns columns as dicts, lists or series.</span>
|
2742 | 2742 | <str> = <DF>.to_json/html/csv([<path>]) <span class="hljs-comment"># Also to_markdown/latex([<path>]).</span>
|
2743 |
| -<DF>.to_pickle/excel(<path>) <span class="hljs-comment"># Run `$ pip3 install openpyxl` for xlsx files.</span> |
| 2743 | +<DF>.to_pickle/excel(<path>) <span class="hljs-comment"># Run `$ pip3 install "pandas[excel]" odfpy`.</span> |
2744 | 2744 | <DF>.to_sql(<span class="hljs-string">'<table_name>'</span>, <connection>) <span class="hljs-comment"># Accepts SQLite3 or SQLAlchemy connection.</span>
|
2745 | 2745 | </code></pre>
|
2746 | 2746 | <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">>>> </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>))
|
@@ -2934,7 +2934,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2934 | 2934 |
|
2935 | 2935 |
|
2936 | 2936 | <footer>
|
2937 |
| - <aside>April 9, 2023</aside> |
| 2937 | + <aside>April 11, 2023</aside> |
2938 | 2938 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2939 | 2939 | </footer>
|
2940 | 2940 |
|
|
0 commit comments