Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6eb148e

Browse files
committed
CSV, Plotly
1 parent ca19a7a commit 6eb148e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,7 @@ import csv
18321832
<writer>.writerows(<coll_of_coll>) # Appends multiple rows.
18331833
```
18341834
* **File must be opened with a `'newline=""'` argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!**
1835+
* **Open existing file with `'mode="w"'` to overwrite it or `'mode="a"'` to append to it.**
18351836

18361837
### Parameters
18371838
* **`'dialect'` - Master parameter that sets the default values. String or a 'csv.Dialect' object.**
@@ -3466,8 +3467,8 @@ def scrape_data():
34663467
return map(pd.Series.rename, out, ['Total Cases', 'Bitcoin', 'Gold', 'Dow Jones'])
34673468

34683469
def wrangle_data(covid, bitcoin, gold, dow):
3469-
df = pd.concat([bitcoin, gold, dow], axis=1) # Joins columns on dates.
3470-
df = df.sort_index().interpolate() # Sorts by date and interpolates NaN-s.
3470+
df = pd.concat([bitcoin, gold, dow], axis=1) # Creates table by joining columns on dates.
3471+
df = df.sort_index().interpolate() # Sorts table by date and interpolates NaN-s.
34713472
df = df.loc['2020-02-23':] # Discards rows before '2020-02-23'.
34723473
df = (df / df.iloc[0]) * 100 # Calculates percentages relative to day 1.
34733474
df = df.join(covid) # Adds column with covid cases.

index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@
15261526

15271527
<ul>
15281528
<li><strong>File must be opened with a <code class="python hljs"><span class="hljs-string">'newline=""'</span></code> argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!</strong></li>
1529+
<li><strong>Open existing file with <code class="python hljs"><span class="hljs-string">'mode="w"'</span></code> to overwrite it or <code class="python hljs"><span class="hljs-string">'mode="a"'</span></code> to append to it.</strong></li>
15291530
</ul>
15301531
<div><h3 id="parameters">Parameters</h3><ul>
15311532
<li><strong><code class="python hljs"><span class="hljs-string">'dialect'</span></code> - Master parameter that sets the default values. String or a 'csv.Dialect' object.</strong></li>
@@ -2824,8 +2825,8 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
28242825
<span class="hljs-keyword">return</span> map(pd.Series.rename, out, [<span class="hljs-string">'Total Cases'</span>, <span class="hljs-string">'Bitcoin'</span>, <span class="hljs-string">'Gold'</span>, <span class="hljs-string">'Dow Jones'</span>])
28252826

28262827
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">wrangle_data</span><span class="hljs-params">(covid, bitcoin, gold, dow)</span>:</span>
2827-
df = pd.concat([bitcoin, gold, dow], axis=<span class="hljs-number">1</span>) <span class="hljs-comment"># Joins columns on dates.</span>
2828-
df = df.sort_index().interpolate() <span class="hljs-comment"># Sorts by date and interpolates NaN-s.</span>
2828+
df = pd.concat([bitcoin, gold, dow], axis=<span class="hljs-number">1</span>) <span class="hljs-comment"># Creates table by joining columns on dates.</span>
2829+
df = df.sort_index().interpolate() <span class="hljs-comment"># Sorts table by date and interpolates NaN-s.</span>
28292830
df = df.loc[<span class="hljs-string">'2020-02-23'</span>:] <span class="hljs-comment"># Discards rows before '2020-02-23'.</span>
28302831
df = (df / df.iloc[<span class="hljs-number">0</span>]) * <span class="hljs-number">100</span> <span class="hljs-comment"># Calculates percentages relative to day 1.</span>
28312832
df = df.join(covid) <span class="hljs-comment"># Adds column with covid cases.</span>

0 commit comments

Comments
 (0)