Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37286e6

Browse files
committed
Logging, Pygame, Pandas
1 parent ac835f5 commit 37286e6

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ import os, shutil, subprocess
17121712
```python
17131713
os.chdir(<path>) # Changes the current working directory.
17141714
os.mkdir(<path>, mode=0o777) # Creates a directory. Permissions are in octal.
1715-
os.makedirs(<path>, mode=0o777) # Creates all path's dirs. Also: `exist_ok=False`.
1715+
os.makedirs(<path>, mode=0o777) # Creates all path's dirs. Also `exist_ok=False`.
17161716
```
17171717

17181718
```python
@@ -2499,7 +2499,7 @@ logging.basicConfig(
24992499
>>> logger.addHandler(handler)
25002500
>>> logger.critical('Running out of disk space.')
25012501
CRITICAL:my_module:Running out of disk space.
2502-
>>> open('test.log').read()
2502+
>>> print(open('test.log').read())
25032503
2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
25042504
```
25052505

@@ -3020,13 +3020,13 @@ while not pg.event.get(pg.QUIT):
30203020
<Surf> = pg.display.set_mode((width, height)) # Opens new window and returns its surface.
30213021
<Surf> = pg.Surface((width, height)) # New RGB surface. RGBA if `flags=pg.SRCALPHA`.
30223022
<Surf> = pg.image.load(<path/file>) # Loads the image. Format depends on source.
3023-
<Surf> = pg.surfarray.make_surface(<np_array>) # Also `<array> = surfarray.pixels3d(<Surf>)`.
3023+
<Surf> = pg.surfarray.make_surface(<np_array>) # Also `<np_arr> = surfarray.pixels3d(<Surf>)`.
30243024
<Surf> = <Surf>.subsurface(<Rect>) # Returns a subsurface.
30253025
```
30263026

30273027
```python
30283028
<Surf>.fill(color) # Tuple, Color('#rrggbb[aa]') or Color(<name>).
3029-
<Surf>.set_at((x, y), color) # Updates pixel.
3029+
<Surf>.set_at((x, y), color) # Updates pixel. Also <Surf>.get_at((x, y)).
30303030
<Surf>.blit(<Surf>, (x, y)) # Draws passed surface to the surface.
30313031
```
30323032

@@ -3357,7 +3357,7 @@ plt.show() # Displays the plot. Also plt.sav
33573357
```python
33583358
<dict> = <DF>.to_dict(['d/l/s/…']) # Returns columns as dicts, lists or series.
33593359
<str> = <DF>.to_json/html/csv([<path>]) # Also to_markdown/latex([<path>]).
3360-
<DF>.to_pickle/excel(<path>) # Run `$ pip3 install openpyxl` for xlsx files.
3360+
<DF>.to_pickle/excel(<path>) # Run `$ pip3 install "pandas[excel]" odfpy`.
33613361
<DF>.to_sql('<table_name>', <connection>) # Accepts SQLite3 or SQLAlchemy connection.
33623362
```
33633363

index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>April 9, 2023</aside>
57+
<aside>April 11, 2023</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -1439,7 +1439,7 @@
14391439

14401440
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes the current working directory.</span>
14411441
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory. Permissions are in octal.</span>
1442-
os.makedirs(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates all path's dirs. Also: `exist_ok=False`.</span>
1442+
os.makedirs(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates all path's dirs. Also `exist_ok=False`.</span>
14431443
</code></pre>
14441444
<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>
14451445
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
20482048
<span class="hljs-meta">&gt;&gt;&gt; </span>logger.addHandler(handler)
20492049
<span class="hljs-meta">&gt;&gt;&gt; </span>logger.critical(<span class="hljs-string">'Running out of disk space.'</span>)
20502050
CRITICAL:my_module:Running out of disk space.
2051-
<span class="hljs-meta">&gt;&gt;&gt; </span>open(<span class="hljs-string">'test.log'</span>).read()
2051+
<span class="hljs-meta">&gt;&gt;&gt; </span>print(open(<span class="hljs-string">'test.log'</span>).read())
20522052
2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
20532053
</code></pre></div>
20542054

@@ -2463,13 +2463,13 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
24632463
<div><h3 id="surface">Surface</h3><p><strong>Object for representing images.</strong></p><pre><code class="python language-python hljs">&lt;Surf&gt; = pg.display.set_mode((width, height)) <span class="hljs-comment"># Opens new window and returns its surface.</span>
24642464
&lt;Surf&gt; = pg.Surface((width, height)) <span class="hljs-comment"># New RGB surface. RGBA if `flags=pg.SRCALPHA`.</span>
24652465
&lt;Surf&gt; = pg.image.load(&lt;path/file&gt;) <span class="hljs-comment"># Loads the image. Format depends on source.</span>
2466-
&lt;Surf&gt; = pg.surfarray.make_surface(&lt;np_array&gt;) <span class="hljs-comment"># Also `&lt;array&gt; = surfarray.pixels3d(&lt;Surf&gt;)`.</span>
2466+
&lt;Surf&gt; = pg.surfarray.make_surface(&lt;np_array&gt;) <span class="hljs-comment"># Also `&lt;np_arr&gt; = surfarray.pixels3d(&lt;Surf&gt;)`.</span>
24672467
&lt;Surf&gt; = &lt;Surf&gt;.subsurface(&lt;Rect&gt;) <span class="hljs-comment"># Returns a subsurface.</span>
24682468
</code></pre></div>
24692469

24702470

24712471
<pre><code class="python language-python hljs">&lt;Surf&gt;.fill(color) <span class="hljs-comment"># Tuple, Color('#rrggbb[aa]') or Color(&lt;name&gt;).</span>
2472-
&lt;Surf&gt;.set_at((x, y), color) <span class="hljs-comment"># Updates pixel.</span>
2472+
&lt;Surf&gt;.set_at((x, y), color) <span class="hljs-comment"># Updates pixel. Also &lt;Surf&gt;.get_at((x, y)).</span>
24732473
&lt;Surf&gt;.blit(&lt;Surf&gt;, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span>
24742474
</code></pre>
24752475
<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
27402740
</code></pre>
27412741
<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>
27422742
&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>
2743-
&lt;DF&gt;.to_pickle/excel(&lt;path&gt;) <span class="hljs-comment"># Run `$ pip3 install openpyxl` for xlsx files.</span>
2743+
&lt;DF&gt;.to_pickle/excel(&lt;path&gt;) <span class="hljs-comment"># Run `$ pip3 install "pandas[excel]" odfpy`.</span>
27442744
&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>
27452745
</code></pre>
27462746
<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>))
@@ -2934,7 +2934,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29342934

29352935

29362936
<footer>
2937-
<aside>April 9, 2023</aside>
2937+
<aside>April 11, 2023</aside>
29382938
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29392939
</footer>
29402940

parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const LOGGING_EXAMPLE =
203203
'<span class="hljs-meta">&gt;&gt;&gt; </span>logger.addHandler(handler)\n' +
204204
'<span class="hljs-meta">&gt;&gt;&gt; </span>logger.critical(<span class="hljs-string">\'Running out of disk space.\'</span>)\n' +
205205
'CRITICAL:my_module:Running out of disk space.\n' +
206-
'<span class="hljs-meta">&gt;&gt;&gt; </span>open(<span class="hljs-string">\'test.log\'</span>).read()\n' +
206+
'<span class="hljs-meta">&gt;&gt;&gt; </span>print(open(<span class="hljs-string">\'test.log\'</span>).read())\n' +
207207
'2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.\n';
208208

209209
const AUDIO =

0 commit comments

Comments
 (0)