<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
<S> = <S>.combine_first(<S>) <spanclass="hljs-comment"># Adds items that are not yet present.</span>
<S>.update(<S>) <spanclass="hljs-comment"># Updates items that are already present.</span>
</code></pre>
<pre><codeclass="python language-python hljs"><S>.plot.line/area/bar/pie/hist() <spanclass="hljs-comment"># Generates a plot. Accepts `title=<str>`.</span>
plt.show() <spanclass="hljs-comment"># Displays the plot. Also plt.savefig(<path>).</span>
<pre><codeclass="python language-python hljs"><S>.plot.line/area/bar/pie/hist() <spanclass="hljs-comment"># Generates a plot. `plt.show()` displays it.</span>
</code></pre>
<ul>
<li><strong>Indexing objects can't be tuples because <codeclass="python hljs"><spanclass="hljs-string">'obj[x, y]'</span></code> is converted to <codeclass="python hljs"><spanclass="hljs-string">'obj[(x, y)]'</span></code>!</strong></li>
<li><strong>Pandas uses NumPy types like <codeclass="python hljs"><spanclass="hljs-string">'np.int64'</span></code>. Series is converted to <codeclass="python hljs"><spanclass="hljs-string">'float64'</span></code> if we assign np.nan to any item. Use <codeclass="python hljs"><spanclass="hljs-string">'<S>.astype(<str/type>)'</span></code> to get converted Series.</strong></li>
<li><strong>Series will silently overflow if we run <codeclass="python hljs"><spanclass="hljs-string">'pd.Series([100], dtype="int8") + 100'</span></code>.</strong></li>
<li><strong>Methods ffill(), interpolate(), fillna() and dropna() accept <codeclass="python hljs"><spanclass="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 <codeclass="python hljs"><spanclass="hljs-string">'<S>[key_1, key_2]'</span></code> to get its values.</strong></li>
</ul>
<div><h3id="dataframe">DataFrame</h3><p><strong>Table with labeled rows and columns.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>df = pd.DataFrame([[<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>], [<spanclass="hljs-number">3</span>, <spanclass="hljs-number">4</span>]], index=[<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>], columns=[<spanclass="hljs-string">'x'</span>, <spanclass="hljs-string">'y'</span>]); df
@ -2924,7 +2924,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
xxxxxxxxxx