# COMP0233 - Day 4 (27th October 2022)
:::info
## :tada: Welcome to the fourth day! :capital_abcd: and :snake:
### Today
Today we will look at programmatically working with data files and sources in Python.
- Review the homework and answer questions
- Continue analysing the earthquakes dataset and create a plot
- Review each other's solution and discuss
:::
:::danger
**Only use zoom if you are connecting remotely**
Remember to `rename` yourself by clicking on your zoom name (in the participants list) and change it to:
`SXXX` where XXX is the room number (105, 121 or 406 or 000 for the online attendees).
If you disconnect and connect again, please rename yourself again.
**Use Youtube If you are in class***
⏯ [streaming - youtube](https://youtu.be/1va91n4FLUk)
:::
### Review from last week
- Python syntax and language features
- Built-in Python data structures (e.g. lists, dictionaries)
- Homework: using comprehensions to iterate over data
#### What was discussed during the week :newspaper:
- Working with files in Python
- Programmatically reading and writing structured data (CSV, YAML, JSON)
- Getting data from online sources
- Producing plots
- Collaboration videos
- [New wiki](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/wiki) to share your favourite tools, tricks and whatever you want (you can see updates on the sidebar in moodle).
- Coursework: Released yesterday. Some more information at the end of the class!
### Groups :handshake:
Got your pair? - 🙋 if you haven't.
:::warning
:question: What was the last programming language you used outside of this course, and for what?
:::
### Poll: homework
:::info
Two quick questions about the homework exercise.
Go to [the voting page][menti]!
:::
### Discussion of homework
In your pairs (and the one next to you), discuss the exercises you did before the class. What did you find difficult or useful? What surprised you in other people's solutions? One of you to write some notes below.
-
-
- Issues with PyYAML (Module not found, despite being installed) - solved by changing python interpreter
-
- JSON formatting: it took a while to see the structure the in the dictionary
-
-
-
- Working with JSON files. We were suprised that many ways to solve the same questions.
-
-
- Getting to grips with .json befores with python
-
-
-
-
- getting a json file from the url
- too many subcategories in the earthquake structure
-
- Acessing deeper levels lists/dictionaries
-
-
-
- how to save a string to th json file and load it within one 'with open' operation?
-
-
-
-
-
- Found it useful to use list comprehension and nested dictionaries.
-
-
-
-
-
-
-
-
-
-
-
-
### Poll: Data formats
:::info
Which data formats have you used and for what?
Go to [the voting page][menti]!
:::
### Exercise: Plotting the quakes dataset
:::info
For this exercise, we will work with the same data to produce two relevant plots!
In smaller groups, discuss what steps you need to take, come up with a plan, and start developing your solution.
Classwork repo: [:hash::one::seven:](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/issues/17)
<br>
:::spoiler Remote? Call for help from your breakout room
If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls.
If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA).
:::
### Dicsussion of the plotting exercise
With the groups around you, discuss the exercise. For example:
- Could you reuse your previous work easily? Why/why not?
- Did you use any external libraries?
- What was the hardest part?
Ask about things you were unsure of, and point out anything you found interesting or unexpected. Choose one person from the group to add notes below.
- Easy to find solutions to the errors we run into, as we could search them up online and find the mistake very swiftly.
- External Library used: numpy, JSON, matplotlib.pyplot, requests
-
-
- o
-
- Reused the functions to extract the data, because the same file and data is required. Used matplotlib, json and requests. Hardesrt part was (everything) in specific list comprehentions and formatting, had trouble seeing where plot is displayed. (please dont delete, thanks:)
-
-
-
- Learnt new python functions and used them in creating the right variables for plots
- Forgot to put plt.show() and then were looking for plots everywhere
- If you use Spyder you don't have to do this
- Thanks!:)
- Thanks!!! :D
-
-
-
-
- creating the dictionary and trying to fit list comprehension in one line
-
-
-
-
-
- getting nice looking x-ticks took a bit of hacky code
-
-
-
-
-
- Unexpected nonetype in list of values
-
-
-
-
-
-
-
-
-
-
### End of class feedback
Confidence check: [menti.com][menti]!
### Homework
- Feedback form on Moodle
- Optional resources on other data formats, plotting frameworks (links in Moodle!) and databases
- Preparation for week 5
- Assignment released.
# Questions
:::info
Feel free to add any question below. Remember the syntax:
```
- Example question
- [name=student_a] Example answer
- [name=TA_1] Example answer
```
:::
-
- [name=]
- .
- [name=...]
- .
- [name=...]
###### tags: `COMP0233` `teaching` `class`
[menti]: https://www.menti.com/alqgdusyjres