Skip to content

Commit 05fcd2d

Browse files
committed
Added Plotly plots
1 parent cc94902 commit 05fcd2d

File tree

7 files changed

+353
-245
lines changed

7 files changed

+353
-245
lines changed

README.md

Lines changed: 79 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,22 +3127,22 @@ dtype: int64
31273127
```
31283128

31293129
```python
3130-
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
3131-
'sum' ['sum'] {'s': 'sum'}
3132-
┠─────────────┼─────────────┼─────────────┼───────────────┨
3133-
sr.apply(…) 3 sum 3 s 3
3134-
sr.agg(…)
3135-
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
3130+
+-------------+-------------+-------------+---------------+
3131+
| | 'sum' | ['sum'] | {'s': 'sum'} |
3132+
+-------------+-------------+-------------+---------------+
3133+
| sr.apply(…) | 3 | sum 3 | s 3 |
3134+
| sr.agg(…) | | | |
3135+
+-------------+-------------+-------------+---------------+
31363136
```
31373137

31383138
```python
3139-
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
3140-
'rank' ['rank'] {'r': 'rank'}
3141-
┠─────────────┼─────────────┼─────────────┼───────────────┨
3142-
sr.apply(…) rank
3143-
sr.agg(…) x 1 x 1 r x 1
3144-
sr.trans(…) y 2 y 2 y 2
3145-
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
3139+
+-------------+-------------+-------------+---------------+
3140+
| | 'rank' | ['rank'] | {'r': 'rank'} |
3141+
+-------------+-------------+-------------+---------------+
3142+
| sr.apply(…) | | rank | |
3143+
| sr.agg(…) | x 1 | x 1 | r x 1 |
3144+
| sr.trans(…) | y 2 | y 2 | y 2 |
3145+
+-------------+-------------+-------------+---------------+
31463146
```
31473147

31483148
### DataFrame
@@ -3198,35 +3198,35 @@ c 6 7
31983198
```
31993199

32003200
```python
3201-
┏━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┓
3202-
how/join 'outer' 'inner' 'left' description
3203-
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
3204-
l.merge(r, on='y', x y z x y z x y z Joins/merges on column.
3205-
how=…) 0 1 2 . 3 4 5 1 2 . Also accepts left_on and
3206-
1 3 4 5 3 4 5 right_on parameters.
3207-
2 . 6 7 Uses 'inner' by default.
3208-
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
3209-
l.join(r, lsuffix='l', x yl yr z x yl yr z Joins/merges on row_keys.
3210-
rsuffix='r', a 1 2 . . x yl yr z 1 2 . . Uses 'left' by default.
3211-
how=…) b 3 4 4 5 3 4 4 5 3 4 4 5
3212-
c . . 6 7
3213-
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
3214-
pd.concat([l, r], x y z y Adds rows at the bottom.
3215-
axis=0, a 1 2 . 2 Uses 'outer' by default.
3216-
join=…) b 3 4 . 4 By default works the
3217-
b . 4 5 4 same as `l.append(r)`.
3218-
c . 6 7 6
3219-
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
3220-
pd.concat([l, r], x y y z Adds columns at the
3221-
axis=1, a 1 2 . . x y y z right end.
3222-
join=…) b 3 4 4 5 3 4 4 5 Uses 'outer' by default.
3223-
c . . 6 7
3224-
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
3225-
l.combine_first(r) x y z Adds missing rows and
3226-
a 1 2 . columns.
3227-
b 3 4 5
3228-
c . 6 7
3229-
┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
3201+
+------------------------+---------------+------------+------------+--------------------------+
3202+
| how/join | 'outer' | 'inner' | 'left' | description |
3203+
+------------------------+---------------+------------+------------+--------------------------+
3204+
| l.merge(r, on='y', | x y z | x y z | x y z | Joins/merges on column. |
3205+
| how=…) | 0 1 2 . | 3 4 5 | 1 2 . | Also accepts left_on and |
3206+
| | 1 3 4 5 | | 3 4 5 | right_on parameters. |
3207+
| | 2 . 6 7 | | | Uses 'inner' by default. |
3208+
+------------------------+---------------+------------+------------+--------------------------+
3209+
| l.join(r, lsuffix='l', | x yl yr z | | x yl yr z | Joins/merges on row_keys.|
3210+
| rsuffix='r', | a 1 2 . . | x yl yr z | 1 2 . . | Uses 'left' by default. |
3211+
| how=…) | b 3 4 4 5 | 3 4 4 5 | 3 4 4 5 | |
3212+
| | c . . 6 7 | | | |
3213+
+------------------------+---------------+------------+------------+--------------------------+
3214+
| pd.concat([l, r], | x y z | y | | Adds rows at the bottom. |
3215+
| axis=0, | a 1 2 . | 2 | | Uses 'outer' by default. |
3216+
| join=…) | b 3 4 . | 4 | | By default works the |
3217+
| | b . 4 5 | 4 | | same as `l.append(r)`. |
3218+
| | c . 6 7 | 6 | | |
3219+
+------------------------+---------------+------------+------------+--------------------------+
3220+
| pd.concat([l, r], | x y y z | | | Adds columns at the |
3221+
| axis=1, | a 1 2 . . | x y y z | | right end. |
3222+
| join=…) | b 3 4 4 5 | 3 4 4 5 | | Uses 'outer' by default. |
3223+
| | c . . 6 7 | | | |
3224+
+------------------------+---------------+------------+------------+--------------------------+
3225+
| l.combine_first(r) | x y z | | | Adds missing rows and |
3226+
| | a 1 2 . | | | columns. |
3227+
| | b 3 4 5 | | | |
3228+
| | c . 6 7 | | | |
3229+
+------------------------+---------------+------------+------------+--------------------------+
32303230
```
32313231

32323232
#### Aggregate, Transform, Map:
@@ -3245,24 +3245,24 @@ b 3 4
32453245
```
32463246

32473247
```python
3248-
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
3249-
'sum' ['sum'] {'x': 'sum'}
3250-
┠─────────────┼─────────────┼─────────────┼───────────────┨
3251-
df.apply(…) x y
3252-
df.agg(…) x 4 sum 4 6 x 4
3253-
y 6
3254-
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
3248+
+-------------+-------------+-------------+---------------+
3249+
| | 'sum' | ['sum'] | {'x': 'sum'} |
3250+
+-------------+-------------+-------------+---------------+
3251+
| df.apply(…) | | x y | |
3252+
| df.agg(…) | x 4 | sum 4 6 | x 4 |
3253+
| | y 6 | | |
3254+
+-------------+-------------+-------------+---------------+
32553255
```
32563256

32573257
```python
3258-
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
3259-
'rank' ['rank'] {'x': 'rank'}
3260-
┠─────────────┼─────────────┼─────────────┼───────────────┨
3261-
df.apply(…) x y x y x
3262-
df.agg(…) a 1 1 rank rank a 1
3263-
df.trans(…) b 2 2 a 1 1 b 2
3264-
b 2 2
3265-
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
3258+
+-------------+-------------+-------------+---------------+
3259+
| | 'rank' | ['rank'] | {'x': 'rank'} |
3260+
+-------------+-------------+-------------+---------------+
3261+
| df.apply(…) | x y | x y | x |
3262+
| df.agg(…) | a 1 1 | rank rank | a 1 |
3263+
| df.trans(…) | b 2 2 | a 1 1 | b 2 |
3264+
| | | b 2 2 | |
3265+
+-------------+-------------+-------------+---------------+
32663266
```
32673267

32683268
#### Encode, Decode:
@@ -3315,20 +3315,20 @@ c 7 8
33153315
```
33163316

33173317
```python
3318-
┏━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┓
3319-
'sum' 'rank' ['rank'] {'x': 'rank'}
3320-
┠─────────────┼─────────────┼─────────────┼─────────────┼───────────────┨
3321-
gb.agg(…) x y x y x y x
3322-
z a 1 1 rank rank a 1
3323-
3 1 2 b 1 1 a 1 1 b 1
3324-
6 11 13 c 2 2 b 1 1 c 2
3325-
c 2 2
3326-
┠─────────────┼─────────────┼─────────────┼─────────────┼───────────────┨
3327-
gb.trans(…) x y x y
3328-
a 1 2 a 1 1
3329-
b 11 13 b 1 1
3330-
c 11 13 c 1 1
3331-
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛
3318+
+-------------+-------------+-------------+-------------+---------------+
3319+
| | 'sum' | 'rank' | ['rank'] | {'x': 'rank'} |
3320+
+-------------+-------------+-------------+-------------+---------------+
3321+
| gb.agg(…) | x y | x y | x y | x |
3322+
| | z | a 1 1 | rank rank | a 1 |
3323+
| | 3 1 2 | b 1 1 | a 1 1 | b 1 |
3324+
| | 6 11 13 | c 2 2 | b 1 1 | c 2 |
3325+
| | | | c 2 2 | |
3326+
+-------------+-------------+-------------+-------------+---------------+
3327+
| gb.trans(…) | x y | x y | | |
3328+
| | a 1 2 | a 1 1 | | |
3329+
| | b 11 13 | b 1 1 | | |
3330+
| | c 11 13 | c 1 1 | | |
3331+
+-------------+-------------+-------------+-------------+---------------+
33323332
```
33333333

33343334
### Rolling
@@ -3344,30 +3344,10 @@ c 7 8
33443344
Plotly
33453345
------
33463346

3347-
### Top 10 Countries by Percentage of Population With Confirmed COVID-19 Infection
3348-
```text
3349-
|
3350-
|
3351-
|
3352-
|
3353-
|
3354-
|
3355-
|
3356-
|
3357-
|
3358-
|
3359-
|
3360-
|
3361-
|
3362-
|
3363-
|
3364-
|
3365-
|
3366-
|
3367-
|
3368-
|
3369-
+----------------------------------------------------------------------------------------------
3370-
```
3347+
### Covid Deaths by Continent
3348+
3349+
<div id="2a950764-39fc-416d-97fe-0a6226a3095f" class="plotly-graph-div" style="height:420px; width:100%;"></div>
3350+
</div>
33713351

33723352
```python
33733353
import pandas as pd
@@ -3381,35 +3361,14 @@ continents = pd.read_csv('https://datahub.io/JohnSnowLabs/country-and-continent-
33813361
merged = pd.merge(covid, continents, left_on='iso_code', right_on='Three_Letter_Country_Code')
33823362
summed = merged.groupby(['Continent_Name', 'date']).sum().reset_index()
33833363
summed['Total Deaths per Million'] = summed.total_deaths * 1e6 / summed.population
3384-
summed = summed[('2020-03-14' < summed.date) & (summed.date < '2020-05-31')]
3364+
summed = summed[('2020-03-14' < summed.date) & (summed.date < '2020-06-25')]
33853365
summed = summed.rename({'date': 'Date', 'Continent_Name': 'Continent'}, axis='columns')
33863366
plotly.express.line(summed, x='Date', y='Total Deaths per Million', color='Continent').show()
33873367
```
33883368

3389-
### Confirmed Cases of COVID-19, Dow Jones Index, Gold, and Bitcoin Price
3390-
```text
3391-
|
3392-
|
3393-
|
3394-
|
3395-
|
3396-
|
3397-
|
3398-
|
3399-
|
3400-
|
3401-
|
3402-
|
3403-
|
3404-
|
3405-
|
3406-
|
3407-
|
3408-
|
3409-
|
3410-
|
3411-
+----------------------------------------------------------------------------------------------
3412-
```
3369+
### Confirmed Covid Cases, Dow Jones, Gold, and Bitcoin Price
3370+
3371+
<div id="e23ccacc-a456-478b-b467-7282a2165921" class="plotly-graph-div" style="height:400px; width:100%;"></div>
34133372

34143373
```python
34153374
import pandas, datetime

0 commit comments

Comments
 (0)