* **The way `'aggregate()'` and `'transform()'` find out whether a function accepts an element or the whole Series is by passing it a single value at first and if it raises an error, then they pass it the whole Series.**
#### Apply, Aggregate, Transform:
```python
>>> sr = Series([1, 2], index=['x', 'y'], name='a')
<li><strong>Also: <codeclass="python hljs"><spanclass="hljs-string">'ffill()'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'interpolate()'</span></code>.</strong></li>
<li><strong>The way <codeclass="python hljs"><spanclass="hljs-string">'aggregate()'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'transform()'</span></code> find out whether a function accepts an element or the whole Series is by passing it a single value at first and if it raises an error, then they pass it the whole Series.</strong></li>
<li><strong>Also: <codeclass="python hljs"><spanclass="hljs-string">'ffill()'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'interpolate()'</span></code>.</strong></li>
<li><strong>All operations operate on columns by default. Use <codeclass="python hljs"><spanclass="hljs-string">'axis=1'</span></code> parameter to process the rows instead.</strong></li>
| df.agg(…) | x <spanclass="hljs-number">4</span> | sum <spanclass="hljs-number">4</span><spanclass="hljs-number">6</span> | x <spanclass="hljs-number">4</span> |
| df.trans(…) | y <spanclass="hljs-number">6</span> | | |
| df.agg(…) | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | rank rank | a <spanclass="hljs-number">1</span> |
| df.trans(…) | b <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | b <spanclass="hljs-number">2</span> |
| | | b <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | |
<li><strong>Transform() doesen't work with <codeclass="python hljs">[<spanclass="hljs-string">'sum'</span>]</code> and <codeclass="python hljs">{<spanclass="hljs-string">'x'</span>: <spanclass="hljs-string">'sum'</span>}</code>.</strong></li>
<div><h3id="groupby">GroupBy</h3><p><strong>Object that groups together rows of a dataframe based on the value of passed column.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>df = DataFrame([[<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>, <spanclass="hljs-number">3</span>], [<spanclass="hljs-number">4</span>, <spanclass="hljs-number">5</span>, <spanclass="hljs-number">6</span>], [<spanclass="hljs-number">7</span>, <spanclass="hljs-number">8</span>, <spanclass="hljs-number">6</span>]], index=list(<spanclass="hljs-string">'abc'</span>), columns=list(<spanclass="hljs-string">'xyz'</span>))
<pre><codeclass="python language-python hljs"><GB> = <DF>.groupby(column_key/s) <spanclass="hljs-comment"># DF is split into groups based on passed column.</span>
<DF> = <GB>.get_group(group_key) <spanclass="hljs-comment"># Selects a group by value of grouping column.</span>
<DF> = <GB>.<operation>() <spanclass="hljs-comment"># Executes operation on each col of each group.</span>
</code></pre>
<ul>
<li><strong>Result of an operation is a dataframe with index made up of group keys. Use <codeclass="python hljs"><spanclass="hljs-string">'<DF>.reset_index()'</span></code> to move the index back into it's own column.</strong></li>
<li><strong>Also: <codeclass="python hljs"><spanclass="hljs-string">'ffill()'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'interpolate()'</span></code>.</strong></li>
<li><strong>All operations operate on columns by default. Use <codeclass="python hljs"><spanclass="hljs-string">'axis=1'</span></code> parameter to process the rows instead.</strong></li>
| | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | rank rank | a <spanclass="hljs-number">1</span> |
| | b <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | b <spanclass="hljs-number">1</span> |
| | c <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | b <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | c <spanclass="hljs-number">2</span> |
| | | c <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | |
| df.agg(…) | x <spanclass="hljs-number">4</span> | sum <spanclass="hljs-number">4</span><spanclass="hljs-number">6</span> | x <spanclass="hljs-number">4</span> |
| df.agg(…) | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | rank rank | a <spanclass="hljs-number">1</span> |
| df.trans(…) | b <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | b <spanclass="hljs-number">2</span> |
| | | b <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | |
<div><h3id="groupby">GroupBy</h3><p><strong>Object that groups together rows of a dataframe based on the value of passed column.</strong></p><pre><codeclass="python language-python hljs"><GB> = <DF>.groupby(column_key/s) <spanclass="hljs-comment"># DF is split into groups based on passed column.</span>
<DF> = <GB>.get_group(group_key) <spanclass="hljs-comment"># Selects a group by value of grouping column.</span>
| | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | rank rank | a <spanclass="hljs-number">1</span> |
| | b <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | a <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | b <spanclass="hljs-number">1</span> |
| | c <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | b <spanclass="hljs-number">1</span><spanclass="hljs-number">1</span> | c <spanclass="hljs-number">2</span> |
| | | c <spanclass="hljs-number">2</span><spanclass="hljs-number">2</span> | |
<Sr/DF/DF> = <Rl_S/D/G>.apply(<agg_func>) <spanclass="hljs-comment"># Invokes function on every window.</span>
<Sr/DF/DF> = <Rl_S/D/G>.aggregate(<func/str>) <spanclass="hljs-comment"># Invokes function on every window.</span>
</code></pre></div>
<div><h2id="plotly"><ahref="#plotly"name="plotly">#</a>Plotly</h2><div><h3id="top10countriesbypercentageofpopulationwithconfirmedcovid19infection">Top 10 Countries by Percentage of Population With Confirmed COVID-19 Infection</h3><pre><codeclass="text language-text">|
xxxxxxxxxx