Newer
Older
# Table of contents
- [Description](#user-content-description)
- [Install Jupyter on MAC](#user-content-install-jupyter-on-mac)
- [Install Jupyter on Windows MAC Linux](#user-content-install-jupyter-on-windows-mac-linux)
- [How to download a file from github](#user-content-how-to-download-a-file-from-github)
- [Basic examples of python data analysis](#user-content-basic-examples-of-python-data-analysis)
- [List of macros](#user-content-list-of-macros-not-up-to-date)
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
- [Useful links to python packages](#user-content-useful-links-to-python-packages)
# Description
This repository contains
- instructions to install the Jupyter package to run python
- examples of python code for data analysis
# Install Jupyter on MAC
Instructions tested on "Mojave version 10.14.6"
- Open "xterm" application (terminal)
- Install "Xcode" software from App Store
- Install "Homebrew" software (see https://brew.sh/)
- Install python 3
```
brew install python3
```
- Install Jupyter notebook (more info at https://jupyter.org/install.html)
```
pip3 install notebook
```
- Check installed python3 packages
```
pip3 list
```
- Install useful packages (if not already in the list)
```
pip3 install numpy
pip3 install matplotlib
pip3 install nbconvert
brew install pandoc
pip3 install scipy
pip3 install pandas
```
Start the jupyter notebook:
```
jupyter notebook
```
Instructions tested on "Windows 10". They work also for other operating systems.
- Download the "Anaconda" software
https://www.anaconda.com/distribution/#download-section --> Download
- Install Anaconda
Start the Anaconda setup file just downloaded (e.g. Anacondaxxx.exe).
Use default options for installation. Wait until installation is finished.
More detailed instructions at: https://docs.anaconda.com/anaconda/user-guide/getting-started/
- Start Jupyter notebook
From Windows Start Menu --> search for "Anaconda navigator" application --> click on the icon to start the application
From the navigator's home click on the "Launch" button under Jupyter tab. This will open jupyter on a browser.
Go in a working directory (you choose the folder name or create a new one) and copy in there the jupyter notebook code examples (.ipynb files plus the input data file when needed). See below how to copy the examples in github in a local working directory on your pc.
# How to download a file from github
Instructions to download a file in the github repository on your pc
- go to the github repository (e.g. https://baltig.infn.it/LabMeccanica/PythonJupyter)
- click on the file (e.g. Basic_Python_Data_Analysis.ipynb)
- click on "Raw" (it will display the raw format for the file)
- click on "File -> Save Page As... ->" (e.g. Basic_Python_Data_Analysis.ipynb); save in the working directory on your pc
Note for Windows:
The process above may not work because the file .ipynb may be recognized incorrectly as a text file instead of a jupyter notebook file.
Therefore better to download directly the full package from github:
- go to the github repository (e.g. https://baltig.infn.it/LabMeccanica/PythonJupyter)
- click on the green button on the right "Clone or download"
- click on download ZIP --> unzip the archive file
- all the content of the package, including the .ipynb example files, are now downloaded on your pc.
# First basic examples of python data analysis
- Download Basic_Python_Data_Analysis.ipynb and data.csv in the
same working directory (follow instructions at previous step)
- From this directory, start the jupyter notebook (e.g. from terminal xterm from MAC)
```
jupyter notebook Basic_Python_Data_Analysis.ipynb
```
- For more info see the documentation/tutorial at https://jupyter-notebook.readthedocs.io/en/stable/
Note for Windows:
You can directly click on the Basic_Python_Data_Analysis.ipynb file from the main jupyter window opened in the browser.
You may need to make the file "Trusted" (there is an icon in the top right of the jupyter window) otherwise jupyter will not execute the program when you run the kernel.
- ```SospettoBaroBayes.ipynb```: application of Bayes theorem. Plot several functions together with a legend.
# Useful links to python packages
- Jupyter documentation: https://jupyter-notebook.readthedocs.io/en/stable/
- Numpy and Scipy documentation: https://docs.scipy.org/doc/ , and in particular https://docs.scipy.org/doc/numpy/reference/
- Pandas dataframes: https://pandas.pydata.org/pandas-docs/stable/getting_started/10min.html#
- Markdown commands: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet