Skip to content

Commit 1e590ad

Browse files
committed
CSV, Pandas a lot of changes
1 parent 2b0ea86 commit 1e590ad

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,8 +1844,8 @@ import csv
18441844
### Parameters
18451845
* **`'dialect'` - Master parameter that sets the default values. String or a 'csv.Dialect' object.**
18461846
* **`'delimiter'` - A one-character string used to separate fields.**
1847-
* **`'lineterminator'` - How writer terminates rows. Reader is hardcoded to '\n', '\r', '\r\n'.**
1848-
* **`'quotechar'` - Character for quoting fields that contain special characters.**
1847+
* **`'lineterminator'` - How writer terminates rows. Reader looks for '\n', '\r' and '\r\n'.**
1848+
* **`'quotechar'` - Character for quoting fields containing delimiters, quotechars, '\n' or '\r'.**
18491849
* **`'escapechar'` - Character for escaping quotechars.**
18501850
* **`'doublequote'` - Whether quotechars inside fields are/get doubled or escaped.**
18511851
* **`'quoting'` - 0: As necessary, 1: All, 2: All but numbers which are read as floats, 3: None.**
@@ -3186,14 +3186,14 @@ Name: a, dtype: int64
31863186

31873187
```python
31883188
<S> = <S>.head/describe/sort_values() # Also <S>.unique/value_counts/round/dropna().
3189-
<S> = <S>.str.strip/lower/contains/replace() # Also split().str[<int>] and split().explode().
3189+
<S> = <S>.str.strip/lower/contains/replace() # Also split().str[i] or split(expand=True).
31903190
<S> = <S>.dt.year/month/day/hour # Use pd.to_datetime(<S>) to get S of dates.
31913191
```
31923192

31933193
```python
31943194
<S>.plot.line/area/bar/pie/hist() # Generates a plot. `plt.show()` displays it.
31953195
```
3196-
* **Also: `'pd.cut(<S>, bins=<int/coll>)'` and `'<S>.quantile(<float/coll>)'`.**
3196+
* **Also `'<S>.quantile(<float/coll>)'` and `'pd.cut(<S>, bins=<int/coll>)'`.**
31973197
* **Indexing objects can't be tuples because `'obj[x, y]'` is converted to `'obj[(x, y)]'`.**
31983198
* **Pandas uses NumPy types like `'np.int64'`. Series is converted to `'float64'` if we assign np.nan to any item. Use `'<S>.astype(<str/type>)'` to get converted Series.**
31993199
* **Series will silently overflow if we run `'pd.Series([100], dtype="int8") + 100'`!**
@@ -3255,7 +3255,7 @@ b 3 4
32553255
```
32563256

32573257
```python
3258-
<DF> = <DF> > <el/S/DF> # Returns DF of bools. S is treated as a row.
3258+
<DF> = <DF> > <el/S/DF> # Returns DF of bools. Treats series as a row.
32593259
<DF> = <DF> + <el/S/DF> # Items with non-matching keys get value NaN.
32603260
```
32613261

@@ -3338,7 +3338,7 @@ c 6 7
33383338
| | b 2.0 2.0 | b 2.0 2.0 | b 2.0 |
33393339
+-----------------+---------------+---------------+---------------+
33403340
```
3341-
* **All methods operate on columns by default. Pass `'axis=1'` to process the rows instead.**
3341+
* **Listed methods process the columns unless they receive `'axis=1'`. Exceptions to this rule are `'<DF>.dropna()'`, `'<DF>.drop(row_key/s)'` and `'<DF>.rename(<dict/func>)'`.**
33423342
* **Fifth result's columns are indexed with a multi-index. This means we need a tuple of column keys to specify a column: `'<DF>.loc[row_key, (col_key_1, col_key_2)]'`.**
33433343

33443344
### Multi-Index

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
<body>
5757
<header>
58-
<aside>February 4, 2025</aside>
58+
<aside>February 5, 2025</aside>
5959
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
6060
</header>
6161

@@ -1529,8 +1529,8 @@
15291529
<div><h3 id="parameters">Parameters</h3><ul>
15301530
<li><strong><code class="python hljs"><span class="hljs-string">'dialect'</span></code> - Master parameter that sets the default values. String or a 'csv.Dialect' object.</strong></li>
15311531
<li><strong><code class="python hljs"><span class="hljs-string">'delimiter'</span></code> - A one-character string used to separate fields.</strong></li>
1532-
<li><strong><code class="python hljs"><span class="hljs-string">'lineterminator'</span></code> - How writer terminates rows. Reader is hardcoded to '\n', '\r', '\r\n'.</strong></li>
1533-
<li><strong><code class="python hljs"><span class="hljs-string">'quotechar'</span></code> - Character for quoting fields that contain special characters.</strong></li>
1532+
<li><strong><code class="python hljs"><span class="hljs-string">'lineterminator'</span></code> - How writer terminates rows. Reader looks for '\n', '\r' and '\r\n'.</strong></li>
1533+
<li><strong><code class="python hljs"><span class="hljs-string">'quotechar'</span></code> - Character for quoting fields containing delimiters, quotechars, '\n' or '\r'.</strong></li>
15341534
<li><strong><code class="python hljs"><span class="hljs-string">'escapechar'</span></code> - Character for escaping quotechars.</strong></li>
15351535
<li><strong><code class="python hljs"><span class="hljs-string">'doublequote'</span></code> - Whether quotechars inside fields are/get doubled or escaped.</strong></li>
15361536
<li><strong><code class="python hljs"><span class="hljs-string">'quoting'</span></code> - 0: As necessary, 1: All, 2: All but numbers which are read as floats, 3: None.</strong></li>
@@ -2595,13 +2595,13 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
25952595
&lt;S&gt; = &lt;S&gt; + &lt;el/S&gt; <span class="hljs-comment"># Items with non-matching keys get value NaN.</span>
25962596
</code></pre>
25972597
<pre><code class="python language-python hljs">&lt;S&gt; = &lt;S&gt;.head/describe/sort_values() <span class="hljs-comment"># Also &lt;S&gt;.unique/value_counts/round/dropna().</span>
2598-
&lt;S&gt; = &lt;S&gt;.str.strip/lower/contains/replace() <span class="hljs-comment"># Also split().str[&lt;int&gt;] and split().explode().</span>
2598+
&lt;S&gt; = &lt;S&gt;.str.strip/lower/contains/replace() <span class="hljs-comment"># Also split().str[i] or split(expand=True).</span>
25992599
&lt;S&gt; = &lt;S&gt;.dt.year/month/day/hour <span class="hljs-comment"># Use pd.to_datetime(&lt;S&gt;) to get S of dates.</span>
26002600
</code></pre>
26012601
<pre><code class="python language-python hljs">&lt;S&gt;.plot.line/area/bar/pie/hist() <span class="hljs-comment"># Generates a plot. `plt.show()` displays it.</span>
26022602
</code></pre>
26032603
<ul>
2604-
<li><strong>Also: <code class="python hljs"><span class="hljs-string">'pd.cut(&lt;S&gt;, bins=&lt;int/coll&gt;)'</span></code> and <code class="python hljs"><span class="hljs-string">'&lt;S&gt;.quantile(&lt;float/coll&gt;)'</span></code>.</strong></li>
2604+
<li><strong>Also <code class="python hljs"><span class="hljs-string">'&lt;S&gt;.quantile(&lt;float/coll&gt;)'</span></code> and <code class="python hljs"><span class="hljs-string">'pd.cut(&lt;S&gt;, bins=&lt;int/coll&gt;)'</span></code>.</strong></li>
26052605
<li><strong>Indexing objects can't be tuples because <code class="python hljs"><span class="hljs-string">'obj[x, y]'</span></code> is converted to <code class="python hljs"><span class="hljs-string">'obj[(x, y)]'</span></code>.</strong></li>
26062606
<li><strong>Pandas uses NumPy types like <code class="python hljs"><span class="hljs-string">'np.int64'</span></code>. Series is converted to <code class="python hljs"><span class="hljs-string">'float64'</span></code> if we assign np.nan to any item. Use <code class="python hljs"><span class="hljs-string">'&lt;S&gt;.astype(&lt;str/type&gt;)'</span></code> to get converted Series.</strong></li>
26072607
<li><strong>Series will silently overflow if we run <code class="python hljs"><span class="hljs-string">'pd.Series([100], dtype="int8") + 100'</span></code>!</strong></li>
@@ -2650,7 +2650,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
26502650
&lt;DF&gt; = &lt;DF&gt;[&lt;S_of_bools&gt;] <span class="hljs-comment"># Filters rows. For example `df[df.x &gt; 1]`.</span>
26512651
&lt;DF&gt; = &lt;DF&gt;[&lt;DF_of_bools&gt;] <span class="hljs-comment"># Assigns NaN to items that are False in bools.</span>
26522652
</code></pre>
2653-
<pre><code class="python language-python hljs">&lt;DF&gt; = &lt;DF&gt; &gt; &lt;el/S/DF&gt; <span class="hljs-comment"># Returns DF of bools. S is treated as a row.</span>
2653+
<pre><code class="python language-python hljs">&lt;DF&gt; = &lt;DF&gt; &gt; &lt;el/S/DF&gt; <span class="hljs-comment"># Returns DF of bools. Treats series as a row.</span>
26542654
&lt;DF&gt; = &lt;DF&gt; + &lt;el/S/DF&gt; <span class="hljs-comment"># Items with non-matching keys get value NaN.</span>
26552655
</code></pre>
26562656
<pre><code class="python language-python hljs">&lt;DF&gt; = &lt;DF&gt;.set_index(col_key) <span class="hljs-comment"># Replaces row keys with column's values.</span>
@@ -2719,7 +2719,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
27192719
</code></pre>
27202720

27212721
<ul>
2722-
<li><strong>All methods operate on columns by default. Pass <code class="python hljs"><span class="hljs-string">'axis=1'</span></code> to process the rows instead.</strong></li>
2722+
<li><strong>Listed methods process the columns unless they receive <code class="python hljs"><span class="hljs-string">'axis=1'</span></code>. Exceptions to this rule are <code class="python hljs"><span class="hljs-string">'&lt;DF&gt;.dropna()'</span></code>, <code class="python hljs"><span class="hljs-string">'&lt;DF&gt;.drop(row_key/s)'</span></code> and <code class="python hljs"><span class="hljs-string">'&lt;DF&gt;.rename(&lt;dict/func&gt;)'</span></code>.</strong></li>
27232723
<li><strong>Fifth result's columns are indexed with a multi-index. This means we need a tuple of column keys to specify a column: <code class="python hljs"><span class="hljs-string">'&lt;DF&gt;.loc[row_key, (col_key_1, col_key_2)]'</span></code>.</strong></li>
27242724
</ul>
27252725
<div><h3 id="multiindex">Multi-Index</h3><pre><code class="python language-python hljs">&lt;DF&gt; = &lt;DF&gt;.loc[row_key_1] <span class="hljs-comment"># Or: &lt;DF&gt;.xs(row_key_1)</span>
@@ -2931,7 +2931,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29312931

29322932

29332933
<footer>
2934-
<aside>February 4, 2025</aside>
2934+
<aside>February 5, 2025</aside>
29352935
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29362936
</footer>
29372937

0 commit comments

Comments
 (0)