You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<DF> = pd.read_pickle/excel(<spanclass="hljs-string">'<path/url>'</span>) <spanclass="hljs-comment"># Use `sheet_name=None` to get all Excel sheets.</span>
2735
-
<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>
2735
+
<DF> = pd.read_sql(<spanclass="hljs-string">'<table/query>'</span>, <conn>) <spanclass="hljs-comment"># SQLite3/SQLAlchemy connection (see #SQLite).</span>
2736
+
<list> = pd.read_html(<path/url/file>) <spanclass="hljs-comment"># Run `$ pip3 install beautifulsoup4 lxml`.</span>
2736
2737
</code></pre></div>
2737
2738
2738
2739
<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>
2739
-
<str> = <DF>.to_json/html/csv/latex() <spanclass="hljs-comment"># Saves output to a file if path is passed.</span>
2740
+
<str> = <DF>.to_json/csv/html/latex() <spanclass="hljs-comment"># Saves output to a file if path is passed.</span>
2740
2741
<DF>.to_pickle/excel(<path>) <spanclass="hljs-comment"># Run `$ pip3 install "pandas[excel]" odfpy`.</span>
2741
2742
<DF>.to_sql(<spanclass="hljs-string">'<table_name>'</span>, <connection>) <spanclass="hljs-comment"># Also `if_exists='fail/replace/append'`.</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>
2747
2748
</ul>
2748
2749
<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>
2749
-
<DF> = <GB>.apply(<func>) <spanclass="hljs-comment"># Maps each group. Func can return DF, S or el.</span>
2750
-
<DF> = <GB>.filter(<func>) <spanclass="hljs-comment"># Drops a group if function returns False.</span>
2750
+
<DF> = <GB>.apply/filter(<func>) <spanclass="hljs-comment"># Filter drops a group if func returns False.</span>
2751
2751
<DF> = <GB>.get_group(<el>) <spanclass="hljs-comment"># Selects a group by grouping column's value.</span>
2752
2752
<S> = <GB>.size() <spanclass="hljs-comment"># S of group sizes. Same keys as get_group().</span>
2753
2753
<GB> = <GB>[col_key] <spanclass="hljs-comment"># Single column GB. All operations return S.</span>
0 commit comments