<DF> = pd.read_pickle/excel(<spanclass="hljs-string">'<path/url>'</span>) <spanclass="hljs-comment"># Use `sheet_name=None` to get all Excel sheets.</span>
<DF> = pd.read_sql(<spanclass="hljs-string">'<table/query>'</span>, <conn.>) <spanclass="hljs-comment"># SQLite3/SQLAlchemy connection (see #SQLite).</span>
<DF> = pd.read_excel(<path/url/file>) <spanclass="hljs-comment"># `sheet_name=None` returns dict of all sheets.</span>
<DF> = pd.read_sql(<spanclass="hljs-string">'<table/query>'</span>, <conn>) <spanclass="hljs-comment"># SQLite3/SQLAlchemy connection (see #SQLite).</span>
<list> = pd.read_html(<path/url/file>) <spanclass="hljs-comment"># Run `$ pip3 install beautifulsoup4 lxml`.</span>
</code></pre></div>
<pre><codeclass="python language-python hljs"><dict> = <DF>.to_dict(<spanclass="hljs-string">'d/l/s/…'</span>) <spanclass="hljs-comment"># Returns columns as dicts, lists or series.</span>
<str> = <DF>.to_json/html/csv/latex() <spanclass="hljs-comment"># Saves output to a file if path is passed.</span>
<str> = <DF>.to_json/csv/html/latex() <spanclass="hljs-comment"># Saves output to a file if path is passed.</span>
<DF>.to_pickle/excel(<path>) <spanclass="hljs-comment"># Run `$ pip3 install "pandas[excel]" odfpy`.</span>
<DF>.to_sql(<spanclass="hljs-string">'<table_name>'</span>, <connection>) <spanclass="hljs-comment"># Also `if_exists='fail/replace/append'`.</span>
</code></pre>
@ -2746,8 +2747,7 @@ c <span class="hljs-number">6</span> <span class="hljs-number">7</span>
<li><strong>To get specific attributes from a series of Timestamps use <codeclass="python hljs"><spanclass="hljs-string">'<S>.dt.year/date/…'</span></code>.</strong></li>
</ul>
<div><h3id="groupby">GroupBy</h3><p><strong>Object that groups together rows of a dataframe based on the value of the passed column.</strong></p><pre><codeclass="python language-python hljs"><GB> = <DF>.groupby(col_key/s) <spanclass="hljs-comment"># Splits DF into groups based on passed column.</span>
<DF> = <GB>.apply(<func>) <spanclass="hljs-comment"># Maps each group. Func can return DF, S or el.</span>
<DF> = <GB>.filter(<func>) <spanclass="hljs-comment"># Drops a group if function returns False.</span>
<DF> = <GB>.apply/filter(<func>) <spanclass="hljs-comment"># Filter drops a group if func returns False.</span>
<DF> = <GB>.get_group(<el>) <spanclass="hljs-comment"># Selects a group by grouping column's value.</span>
<S> = <GB>.size() <spanclass="hljs-comment"># S of group sizes. Same keys as get_group().</span>
<GB> = <GB>[col_key] <spanclass="hljs-comment"># Single column GB. All operations return S.</span>
@ -2924,7 +2924,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active