Python data science 101, Slides
This was a slight update for the 2022/23 lecture on “Python data science 101”. Our aim was to have a more practical introduction to Python visual analytics and introduce some best practices, before we head into the workshop weeks.
Title: Python data science 101 for Social Media Cartography (and beyond)
- Slides (HTML): https://kartographie.geo.tu-dresden.de/ad/python_datascience_2022/
- Repository: gitlab.hrz.tu-chemnitz.de/tud-ifk/python_datascience_2022_slides
This semester, I revised the slides for better code legibility. RevealJS 4.4.0 allows to use new animations (e.g. see slide 61-63), which I used to better explain concepts, such as code formatting conventions. The code line highlighting is also good to break content down into individual pieces (e.g. see slide 57-61).
We also explored how ChatGPT can be used to program.
The question was:
Write a really short python method to download a zip file from an URL and unzip it to a folder.
This is the code that was returned:
|
|
Pretty good.
Compare this to my code on slide 35:
|
|
Instead of the native requests
library, ChatGPT suggests to use urllib.request
(which requests uses under the hood, too). However, requests
provides for a more
simple API. I tested the function from ChatGPT, and it did work out of the box. The customizations
turn out to be more complex using ChatGPT urllib.request
instead of requests
.
For instance, I later had to add headers/user agent to request the zip file, which is easier
in requests
.
Here’s a full code example based on the ChatGPT function
|
|