diff --git a/README.md b/README.md index 4899da1..b5ef95e 100644 --- a/README.md +++ b/README.md @@ -3166,7 +3166,6 @@ Name: a, dtype: int64 ```python <S> = pd.Series(<list>) # Creates index from list's indices. <S> = pd.Series(<dict>) # Creates index from dictionary's keys. -<S> = pd.Series(<dict/Series>, index=<list>) # Only keeps items with keys specified in index. ``` ```python @@ -3193,11 +3192,11 @@ Name: a, dtype: int64 ``` ```python -<S>.plot.line/area/bar/pie/hist() # Generates a plot. Accepts `title=<str>`. -plt.show() # Displays the plot. Also plt.savefig(<path>). +<S>.plot.line/area/bar/pie/hist() # Generates a plot. `plt.show()` displays it. ``` * **Indexing objects can't be tuples because `'obj[x, y]'` is converted to `'obj[(x, y)]'`!** * **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.** +* **Series will silently overflow if we run `'pd.Series([100], dtype="int8") + 100'`.** #### Series — Aggregate, Transform, Map: ```python @@ -3225,6 +3224,7 @@ plt.show() # Displays the plot. Also plt.sav +--------------+-------------+-------------+---------------+ ``` * **Methods ffill(), interpolate(), fillna() and dropna() accept `'inplace=True'`.** +* **Agg/transform() pass Series to functions that raise Type/Value/AttrError on single item.** * **Last result has a multi-index. Use `'<S>[key_1, key_2]'` to get its values.** ### DataFrame diff --git a/index.html b/index.html index 7ba2306..e6f46f4 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@ <body> <header> - <aside>December 3, 2024</aside> + <aside>December 4, 2024</aside> <a href="https://gto76.github.io" rel="author">Jure Šorn</a> </header> @@ -2582,7 +2582,6 @@ Name: a, dtype: int64 <pre><code class="python language-python hljs"><S> = pd.Series(<list>) <span class="hljs-comment"># Creates index from list's indices.</span> <S> = pd.Series(<dict>) <span class="hljs-comment"># Creates index from dictionary's keys.</span> -<S> = pd.Series(<dict/Series>, index=<list>) <span class="hljs-comment"># Only keeps items with keys specified in index.</span> </code></pre> <pre><code class="python language-python hljs"><el> = <S>.loc[key] <span class="hljs-comment"># Or: <S>.iloc[i]</span> <S> = <S>.loc[coll_of_keys] <span class="hljs-comment"># Or: <S>.iloc[coll_of_i]</span> @@ -2599,12 +2598,12 @@ Name: a, dtype: int64 <S> = <S>.combine_first(<S>) <span class="hljs-comment"># Adds items that are not yet present.</span> <S>.update(<S>) <span class="hljs-comment"># Updates items that are already present.</span> </code></pre> -<pre><code class="python language-python hljs"><S>.plot.line/area/bar/pie/hist() <span class="hljs-comment"># Generates a plot. Accepts `title=<str>`.</span> -plt.show() <span class="hljs-comment"># Displays the plot. Also plt.savefig(<path>).</span> +<pre><code class="python language-python hljs"><S>.plot.line/area/bar/pie/hist() <span class="hljs-comment"># Generates a plot. `plt.show()` displays it.</span> </code></pre> <ul> <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> <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">'<S>.astype(<str/type>)'</span></code> to get converted Series.</strong></li> +<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> </ul> <div><h4 id="seriesaggregatetransformmap">Series — Aggregate, Transform, Map:</h4><pre><code class="python language-python hljs"><el> = <S>.sum/max/mean/idxmax/all() <span class="hljs-comment"># Or: <S>.agg(lambda <S>: <el>)</span> <S> = <S>.rank/diff/cumsum/ffill/interpol…() <span class="hljs-comment"># Or: <S>.agg/transform(lambda <S>: <S>)</span> @@ -2629,6 +2628,7 @@ plt.show() <span class="hljs-comment"># Disp <ul> <li><strong>Methods ffill(), interpolate(), fillna() and dropna() accept <code class="python hljs"><span class="hljs-string">'inplace=True'</span></code>.</strong></li> +<li><strong>Agg/transform() pass Series to functions that raise Type/Value/AttrError on single item.</strong></li> <li><strong>Last result has a multi-index. Use <code class="python hljs"><span class="hljs-string">'<S>[key_1, key_2]'</span></code> to get its values.</strong></li> </ul> <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>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>]], 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>]); df @@ -2924,7 +2924,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active <footer> - <aside>December 3, 2024</aside> + <aside>December 4, 2024</aside> <a href="https://gto76.github.io" rel="author">Jure Šorn</a> </footer>