-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslides.html
More file actions
executable file
·505 lines (335 loc) · 13.2 KB
/
slides.html
File metadata and controls
executable file
·505 lines (335 loc) · 13.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
<!DOCTYPE html>
<html>
<head>
<title>Data Wrangling & Plotting in Python</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="static/slides.css">
<link rel="stylesheet" href="./static/font-awesome-4.7.0/css/font-awesome.min.css">
<!-- <style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
#slideshow .slide .content .cols.two .col { width: 48%; }
</style>
-->
<style>
.section_background {background-color:#c2c444; color: #fff}
.day_background {background-color:#ececec; color: #000}
</style>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
</head>
<body>
<textarea id="source">
class: center, middle
# M13 - Upgrade your Python Skills: Data Wrangling & Plotting
Institute for continuing education in Science - ICES<br>
March 7, 10, 14, 17 and 24, 2022
Joris Van den Bossche, Stijn Van Hoey
https://github.com/jorisvandenbossche/ICES-python-data
---
class: center, middle
# Who are you?
Go to https://hackmd.io/zuHWx-doS9ORQGV_1JcXDw?both
<iframe src="https://hackmd.io/zuHWx-doS9ORQGV_1JcXDw?both" height="400px" width="800px"></iframe>
---
### Joris Van den Bossche
<a href="https://twitter.com/jorisvdbossche"><i class="fa fa-twitter" aria-hidden="true"></i> jorisvdbossche</a>,
<a href="https://github.com/jorisvandenbossche"><i class="fa fa-github" aria-hidden="true"></i> jorisvandenbossche</a><br>
* Open source software developer and teacher
* Pandas, GeoPandas, scikit-learn, Apache Arrow
.center[
]
---
### Stijn Van Hoey
<a href="https://twitter.com/svanhoey"><i class="fa fa-twitter" aria-hidden="true"></i> SVanHoey</a>,
<a href="https://github.com/stijnvanhoey"><i class="fa fa-github" aria-hidden="true"></i> stijnvanhoey</a>
* Freelance developer and teacher
* Research software engineer at [Fluves](https://www.fluves.com/)
.center[
]
---
class: middle, section_background
# Setting up a working environment
---
## Setting up a working environment
For the setup instructions, see the [setup page](https://jorisvandenbossche.github.io/ICES-python-data/setup.html).
---
class: left, middle
0. Everyone has conda installed and the environment setup? If not, see [1-install-python-and-the-required-python-packages](https://jorisvandenbossche.github.io/ICES-python-data/setup.html#1-install-python-and-the-required-python-packages)
1. Make sure to (re)download ALL the course material, see [2-getting-the-course-materials](https://jorisvandenbossche.github.io/ICES-python-data/setup.html#2-getting-the-course-materials) also if you already did this before.
2. Next, also do section 3 and 4 of the [setup](https://jorisvandenbossche.github.io/ICES-python-data/setup.html)
> If you succesfully done 1, 2 and 3, put up your `green sticky note` on your laptop screen..
Next:
- Surf to and fill in [the questionnaire](https://hackmd.io/zuHWx-doS9ORQGV_1JcXDw?both)
- In Jupyter Lab, start with the 'notebooks/00-jupyter_introduction.ipynb'.
> Installation or setup issues? Put up your `orange/red/yellow sticky note` on your laptop screen.
---
class: center, middle
When you see something like this...

...relax, you're ready to start!
---
class: center, middle

---
class: middle, left
### Time is divided between
- group sessions: we explain new concepts (aka 'theory')
- practise sessions: you work on exercises
In case of questions, remarks, suggestions, you can always interrupt us and just ask.
During practise sessions, use the `orange/red/yellow sticky note` on top of your laptop screen to let us know you have a question.
### Status check
We will regularly ask for a check (ready with exercise, installation succesfull...). Use the `green sticky note` on top of your laptop screen to say 👍.
### Feel lost?
Just ask either one of us, we are here to help you.
---
class: middle, center

Report bugs, typo's, suggestions... as issues ([New issue](https://github.com/jorisvandenbossche/ICES-python-data/issues/new))
or see the [contributing guidelines](https://github.com/jorisvandenbossche/ICES-python-data/blob/master/CONTRIBUTING.md)
---
class: middle, section_background
# Introduction
---
class: center, middle
index | date
:-----:|:----:
2 | 19930000
8 | 1992-930
27 | 20050500
34 | 201405.01
162 | 7/9/2287
1400 | 0.0
2800 | start of the year 2015
3777 | Summer
8733 | 2013-2016
26766 | 26/09/2002 and later 1/1/2016
40788 | Nan
41277 | /
51002 | -999
51007 | -9999
.center[Never underestimate the creativity of humans!]
---
class: center, middle

---
class: center, middle

---
class: middle, section_background
# Working with Python
---
# Conda
### Why using conda?
- Consistent package manager across Windows, Mac and Linux
- Many precompiled packages available
- Less problems with installation!
--
### Why different environments?
- Manage the dependencies of a specific project/paper/group/...
- You can install different version of Python and other packages alongside on your computer
- Easily share environments with other
---
## Small overview of conda commands
Creating a new environment:
```
conda create -n my_env python=3.9 pandas
# or from environment file
conda env create -f environment.yml
```
Activating an environment:
```
conda activate my_env
```
Install a new package:
```
conda install matplotlib # if not working, try: pip install ...
```
List all installed packages: `conda list`
List all your environments: `conda info -e`
See the docs: http://conda.pydata.org/docs/using/index.html
---
class: center, middle
### Keep track of your python ecosystem <br>with an `environment.yml`
<br><br>
```
conda env export > environment.yml
```
---
# Writing Python code
## IPython console
<br>
.center[]
---
## Interactive Development Environment (IDE)
* [**Spyder**](https://pythonhosted.org/spyder/) is shipped with Anaconda. The familiar environment for Matlab/Rstudio-users...
* [**PyCharm**](https://www.jetbrains.com/pycharm/): Popular for web-development and Django applications, powerful when doing 'real' development (packages, libraries, software)
* [Eclipse + **pyDev plugin**](http://www.pydev.org/): If you like working in Eclipse, just add the python environment
* [**VS Code**](https://code.visualstudio.com/), [**Atom**](https://atom.io/), ...
---
## Jupyter Lab/Notebook
<small>(*previously called IPython notebook*)</small>
**Jupyter notebook** provides an **interactive** scripting environment,<br> ideal for exploration, prototyping,...
.center[]
--
...the stuff we're dealing with in this course!
---
class: middle, section_background
# Pandas
---
class: center, middle

---
## Pandas: data analysis in python
For data-intensive work in Python the [Pandas](http://pandas.pydata.org) library has become essential.
What is `pandas`?
* Pandas can be thought of as *NumPy arrays with labels* for rows and columns, and better support for heterogeneous data types, but it's also much, much more than that.
* Pandas can also be thought of as `R`'s `data.frame` or `tidyverse` in Python.
* Powerful for working with missing data, working with time series data, for reading and writing your data, for reshaping, grouping, merging your data, ...
It's documentation: http://pandas.pydata.org/pandas-docs/stable/
---
## When do you need pandas?
When working with **tabular or structured data** (like R dataframe, SQL table, Excel spreadsheet, ...):
- Import data
- Clean up messy data
- Explore data, gain insight into data
- Process and prepare your data for analysis
- Analyse your data (together with scikit-learn, statsmodels, ...)
---
## Attention!
Pandas is great for working with heterogeneous and tabular 1D/2D data, but not all types of data fit in such structures!
* When working with array data (e.g. images, numerical algorithms): just stick with Numpy
* When working with multidimensional labeled data (e.g. climate data): have a look at [xarray](http://xarray.pydata.org/en/stable/)
---
## Key features
* Fast, easy and flexible input/output for a lot of different data formats
* Working with missing data (`.dropna()`, `pd.isnull()`)
* Merging and joining (`concat`, `join`)
* Grouping: `groupby` functionality
* Reshaping (`stack`, `pivot`)
* Powerful time series manipulation (resampling, timezones, ..)
* Easy plotting
---
class: middle, section_background
# Tidy data
---
class: center, middle
background-image: url(./img/tidy_data_paper.png)
.footnote[Wickham, H. (2014) <br> Tidy Data, Vol. 59, Issue 10, <br> Journal of Statistical Software. doi:10.18637/jss.v059.i10]
---
class: center, middle
| WWTP | Treatment A | Treatment B |
|:------|-------------|-------------|
| Destelbergen | 8. | 6.3 |
| Landegem | 7.5 | 5.2 |
| Dendermonde | 8.3 | 6.2 |
| Eeklo | 6.5 | 7.2 |
---
class: center, middle
| WWTP | Treatment | pH |
|:------|:-------------:|:-------------:|
| Destelbergen | A | 8. |
| Landegem | A | 7.5 |
| Dendermonde | A | 8.3 |
| Eeklo | A | 6.5 |
| Destelbergen | B | 6.3 |
| Landegem | B | 5.2 |
| Dendermonde | B | 6.2 |
| Eeklo | B | 7.2 |
---
class: center, middle
.center[]
---
class: center, middle
# How are you feeling?

### https://forms.gle/UfDRr3hkFtt2JcwGA
Please fill in the questionnaire!
---
class: center, middle
# Closing notes
---
class: center, middle
# Python's scientific ecosystem
#### ## Adjusted from figure by Jake VanderPlas
---
class: center, middle, bgheader
background-image: url(./img/JakeVdP-ecosystem1.svg)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/JakeVdP-ecosystem2.svg)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/JakeVdP-ecosystem3.svg)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/JakeVdP-ecosystem4.svg)
background-size: cover
---
count: false
class: center, middle, bgheader
background-image: url(./img/JakeVdP-ecosystem5.svg)
background-size: cover
---
# A rich ecosystem of packages:
<br>
**Machine learning**: scikit-learn, tensorflow, pytorch, keras, chainer, ...
**Performance**: Numba, Cython, Numexpr, Pythran, C/Fortran wrappers, ...
**Visualisation**: Bokeh, Seaborn, Plotnine, Altair, Plotly, Mayavi, HoloViews, datashader, vaex ...
**Data structures and parallel/distributed computation**: Xarray, Dask, Distributed, Cupy, ...
Specialized packages in many **scientific fields**: astronomy, natural language processing, image processing, geospatial, ...
**Packaging and distribution**: pip/wheels, conda, Anaconda, Canopy, ...
---
class: center, middle
### Reading advice
[Good Enough Practices in Scientific Computing](https://arxiv.org/pdf/1609.00037v1.pdf)
> "*However, while most scientists are careful to validate their laboratory and field equipment, most do not know how reliable their software is*"
---
class: center, middle
# Thanks
### Joris Van den Bossche
<a href="https://twitter.com/jorisvdbossche"><i class="fa fa-twitter" aria-hidden="true"></i> jorisvdbossche</a>,
<a href="https://github.com/jorisvandenbossche"><i class="fa fa-github" aria-hidden="true"></i> jorisvandenbossche</a><br>
### Stijn Van Hoey
<a href="https://twitter.com/svanhoey"><i class="fa fa-twitter" aria-hidden="true"></i> SVanHoey</a>,
<a href="https://github.com/stijnvanhoey"><i class="fa fa-github" aria-hidden="true"></i> stijnvanhoey</a>
</textarea>
<!-- <script src="https://gnab.github.io/remark/downloads/remark-latest.min.js">
</script>-->
<script src="static/remark.min.js" type="text/javascript">
</script>
<script>
var slideshow = remark.create();
</script>
<script>
remark.macros.scale = function (percentage) {
var url = this;
return '<img src="' + url + '" style="width: ' + percentage + '" />';
};
var slideshow = remark.create();
</script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>