# 2024-04 <br> SWD1a: Introduction to Python
**NB**: ask for help! https://bit.ly/arc-help
Welcome to the hack pad for SWD1a course from Research Computing at the University of Leeds!
You can edit this document using [Markdown syntax](https://guides.github.com/features/mastering-markdown/).
## Contents
1. [Links to resource](#Links-to-resources)
2. [Agenda](#Agenda)
5. [Further reading](#Further-reading)
6. [Extra code snippets](#Misc-code-snippets)
## Links to resources
- **Contact Research Computing** - https://bit.ly/arc-help
- **Workshop Slides** - https://swcarpentry.github.io/python-novice-inflammation/
- **Research Computing website** - https://arc.leeds.ac.uk/
### Course Recordings
## Agenda
### Agenda Day 1
| Time | Agenda |
| ---- | ------------------------------------------ |
| 1000 | Intro, using Google Colab, What is Python? |
| 1050 | Break |
| 1100 | Python Fundamentals |
| 1130 | Analyzing Patient Data |
| 1230 | Lunch |
| 1330 | Visualizing Tabular Data: [Colab link](https://colab.research.google.com/drive/1ig5NK-yooLwsqisddqd6Z-_8WAdPt9HB?usp=sharing), [further notes and exercises](https://arctraining.github.io/data-vis/start.html) |
| 1450 | Break |
| 1500 | Storing Multiple Values in Lists |
| 1545 | Questions |
| 1600 | Close |
### Agenda Day 2
| Time | Agenda |
| ---- | ---------------------------------- |
| 1000 | Repeating Actions with Loops |
| 1050 | Break |
| 1100 | Analyzing Data from Multiple Files |
| 1200 | Lunch |
| 1300 | Making Choices |
| 1400 | Creating Functions |
| 1450 | Break |
| 1500 | Errors and Exceptions |
| 1545 | Questions |
| 1600 | Close |
## What's your name and where do you come from?
[Andy Turner](https://github.com/agdturner), IT Services, Instructor, Research Software Engineer. I am interested in scientific computing and have considerable software development expertise. I track the evolution of several programming languages and am experienced in helping researchers learn to code.
[**Maeve Murphy Quinlan**](https://murphyqm.github.io/), a research software engineer in Research computing. I'm joining this afternoon to walk you through some basic data visualisation!
**Callam Milne**, PhD student - Geology
**Ollie Clark** - Research Software Engineer. Experience in Databases, software engineering, information systems. Languages C/C++, Perl, Python.
**Gaia Ferrarin**, PhD Student - Cancer
**Nicole Powell**, PhD Student, Medicine
**Fatima Sabir**, PhD student, geriatric medicine
**Nicola Ingram:** PDRA Physics/Medicine,
**Jonathan Benn**, Academic in Health Services Research
**Cristina Teleanu**, PhD student in Fluid Dynamics CTD, medical engineering applications
**Katrina Freimane**, Academic Doctor
**Adam Al-Hakim**, PhD student in Immunology
**Hayder AlAmeri**, PhD student - School of Civil Engineering
**Aqeelah Mohammad**, PhD student - Medical Research
**Omar Nahhas**, PhD student - school of Biomedical sciences
**Sumona Kumar** - School of EEE
**Naufal**,PhD Student in Geography
**Ziyu Ding**, SAS Programmer
**Rishad Rayyaan**: Research fellow in Composites Repair; School of Design. Main expertises are in manufacturing and mechanics of materials. Now doing finite element modelling and exploring the field of engineering simulations.
**Esra Ermis Akyuz**, PhD Student / Medicine
**Barbara Robar**, PhD student in Neuroscience
**Dr Javaid Anwar**, Postdoctoral Research Assistant, School of Civil Engineering
**Rui Ma**, PhD student - Electronic and Electrical Engineering
**Abhinav Jindal (Jin)** - Information Analyst, NIHR; MSc Business Analytics & Decision Sciences, University of Leeds
**Sameena Kanakkayil** - PhD Student from chemistry*
Gettie Mulokoshi - PhD School of Civil Engineering
**Dr Deepak Arunachalam**-Assistant Professor, Leeds University Business School
## Further reading
- Our detailed data [visualisation in Python course notes](https://arctraining.github.io/data-vis/start.html)
- Python data types: https://realpython.com/python-data-types/
- Using a code notebook effectively: https://saturncloud.io/blog/productive-use-of-jupyter-notebooks-a-guide-for-data-scientists/
- More advanced Jupyter notebook guidance and best practise: https://carpenter-singh-lab.broadinstitute.org/blog/best-practices-jupyter-notebook
- Full **FREE** datascience with Python textbook with code snippets - https://jakevdp.github.io/PythonDataScienceHandbook/
- Full **FREE** computational numerical Modelling in Python book - https://greenteapress.com/ModSimPy/ModSimPy.pdf
- Data indexing and slicing tutorial: https://realpython.com/lessons/indexing-and-slicing/
- Correlation and statistics in Python: https://realpython.com/numpy-scipy-pandas-correlation-python/
- Starting off with Sci-kit learn (from question during the tutorial): https://machinelearningmastery.com/a-gentle-introduction-to-scikit-learn-a-python-machine-learning-library/
- Then a more intensive in-depth work through: https://scikit-learn.org/stable/tutorial/index.html
- Data visualisation: basic package is matplotlib, if you want to move on to more statistical visualisation, then the seaborn package is useful too: https://jakevdp.github.io/PythonDataScienceHandbook/04.14-visualization-with-seaborn.html, here's another good intro tutorial https://medium.com/geekculture/8-best-seaborn-visualizations-20143a4b3b2f
- A brief/quick talk I gave on data vis with some example code notebooks - https://github.com/murphyqm/planetary-group-figures/
- Plotly graphing library - https://plotly.com/python/
- Animations with Matplotlib: https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c, https://www.geeksforgeeks.org/using-matplotlib-for-animations/
- Some details on File systems with Google Colab: https://neptune.ai/blog/google-colab-dealing-with-files. Remember, when you disconnect, all the folders and files attached to your notebook get deleted - this is why every time we need to load and unzip the example data. So download all the figures you create!
- Alternative plotting libraries for specific tasks: https://www.knowledgehut.com/blog/business-intelligence-and-visualization/python-data-visualization-libraries
- Boolean/logic operators in Python: https://www.geeksforgeeks.org/python-operators/
- Add CNN material
## Textbooks
- Full **FREE** datascience with Python textbook with code snippets - https://jakevdp.github.io/PythonDataScienceHandbook/
- Full **FREE** computational numerical Modelling in Python book - https://greenteapress.com/ModSimPy/ModSimPy.pdf
- High Performance Python - Micha Gorelick and Ian Ozsvald. Potentially available online for free too, if you want to borrow the physical textbook send me a message (Maeve)
- Better Data Vizualisations - Jonathan Schwabish; not specific to Python. Also have a physical copy of this you can borrow (Maeve)
- Programming for Computations - Python
A Gentle Introduction to Numerical Simulations with Python 3.6 [link](https://link.springer.com/book/10.1007/978-3-030-16877-3?source=shoppingads&locale=en-gb&gclid=CjwKCAjw4P6oBhBsEiwAKYVkqwZBOacqY0IM-58Jtx8aIdMXWKRSUOVSOie5j0N6wmLTY5Agkal0fRoCXqIQAvD_BwE); I think it's available in lib, I also have a copy if people need.
## Misc code snippets
### Download data
```python=
# Download 2 files and store in the swc-python folder
!wget -P swc-python https://swcarpentry.github.io/python-novice-inflammation/data/python-novice-inflammation-data.zip
!wget -P swc-python https://swcarpentry.github.io/python-novice-inflammation/files/code/python-novice-inflammation-code.zip
```
### Unzip Files
```python=
# Extract .zip files inside the folder swc-python/
!unzip /content/swc-python/python-novice-inflammation-code.zip -d /content/swc-python/
!unzip /content/swc-python/python-novice-inflammation-data.zip -d /content/swc-python/
```
## Installing packages
- Set up an Anaconda environment with all the packages you need: ``conda install package-name``
- Or use pip install - ``pip install package-name`` from terminal
- Read our documentation on using Anaconda - https://arcdocs.leeds.ac.uk/software/compilers/anaconda.html - while this is aimed at users working on the ARC systems, it is also applicable to your local computer
- Using pip instead: https://packaging.python.org/en/latest/tutorials/installing-packages/