- Notifications
You must be signed in to change notification settings - Fork37
pzivich/Python-for-Epidemiologists
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repository is an introduction to epidemiology analyses in Python. Additionally, the tutorials for my libraryzEpid are hosted here. For more information onzEpid, seeGitHub orReadTheDocs.
The directory of this guide is
- Python Basics
- Basics of pandas (data management library)
- Epidemiology analyses in Python
- Basics
- Missing data
- Causal inference
- Time-fixed treatments
- Time-varying treatments
- Sensitivity analyses
To complete the tutorial, user must have the following packages installed:numpy
,pandas
,zepid
,matplotlib
,statsmodels
,lifelines
, andsklearn
No IDE is required to complete the tutorial. All files are available inipynb
also known as jupyter notebooks. Codecan be either downloaded or copied from the notebooks.
Here are some IDEs I have used in the past (and what I believe to be their advantages and disadvantages
Rodeo
This is the IDE I used for a long time. It is set up like RStudio
Advantages:
Basically RStudio but for Python, decent interface, easy to run line-by-line, easy to visualize plots (although itencourage bad habits)
Disadvantages:
Does not have all the features of RStudio (will delete changes if closed without saving), sucks up a lot of memory,sometimes the auto-complete would stop working if I hit more than 300+ lines of code, the environment tab is notgreat (don't expect it to open anything like RStudio)
Aside: their website has great tutorials how to run some basic stuff in Python if you are new to analysis in Pythonhttps://rodeo.yhat.com/
jupyter notebooks
Designed to be like a lab notebook, or like R markdown. Supports a pseudo-line-by-line conceptGood for writing, since it allows for MarkDown. While I know a lot of people like jupyter, I only really use it forexamples of code, not my personal programming. I never liked how it had to open via a Web Browser. I would rather haveit be separate program. However, all guides were made using this IDE
PyCharm
This is the IDE I currently use
Advantages:
Easily set up virtual environments, interacts natively with Git, supports different file formats with plug-ins(e.g. .md), enforces certain coding conventions, better debug code features, organization of files under the projecttab are convenient
Disadvantages:
Not great for running line-by-line code (it can do it, just not as elegantly), little more hardcore (I wouldn't reallyconsider it a beginner's IDE. It requires some knowledge of set-up of Python)
IDLE
Ships with the basic Python 3.x installation. It is very basic and does not support line-by-line. Wouldn't recommendunless you are just starting with Python and don't want to commit to an IDE yet
Spyder
Ships withconda
. Not bad but I didn't use it that much (I couldn't get the hang of it). Similarly it is an RStudiocopy. Can't say too much since I haven't used it extensively
If you have never used Python before, I have created some introductory materials to Python and the data managementlibrary I use,pandas
. These are basic guides, but they also point to other resources. PleaseREAD ALL OF THE BELOWBEFORE PROCEEDING.
To install, Python 3.x, we can download it directly from:https://www.python.org/downloads/
The installer provides an option to add Python3 to PATH, it ishighly recommended you do this, since it allows youto avoid having to do it manually
Open Command Prompt / Terminal. When opened, typepython
and this should open Python in the same window. From here,you can quit by typing 'quit()' or closing the window. If this does NOT work, make sure your environmental variablewas created properly
Packages are what stores Python functions that we will use. These packages are contributed by various members of thecommunity (including me)) and there is a wide array. To be able to download packages, we need to make sure we have anenvironmental variable created for python. We will discuss how to install packages
Python 3.x conveniently comes with a package manager. Basically it stores all the packages and we can use it todownload new ones or update already downloaded ones.
To download a new package: Open Command Prompt/Terminal and use the following code (we will be installing pandas)
pip install pandas
To update a Python package, type the following command into Command Prompt. For example, we will update our pandas package
pip install pandas --upgrade
That concludes the basics. Please review parts 1 and 2 of the tutorials next
About
Tutorial in Python targeted at Epidemiologists. Will discuss the basics of analysis in Python 3
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.