On this page, you will find a short introduction to what Python is and links to the Python tutorials on this site.
FAQ About Python
Before going on with describing the Python tutorials, found on this site, you’ll find answers to some questions:
What is Python?
Python is open source and free programming language, even for commercial applications. The language is usually used, and referred to, as a scripting language. Python is a high-level and general-purpose programming language and due to its flexibility, Python is one of the most popular programming languages. Finally, Python fully supports both object-oriented programming and structured programming.
Why Should I Learn Python?
Why Python? First, as previously mentioned, it is open source and free. There are many, other aspects, that we will not cover here but one of the strongest reasons for Python is that there are a variety of both general-purpose and specialized python libraries.
What Can I use Python for?
Python can be used to do data collection (e.g., scrape the Web or software psychological experiments) using Python. Furthermore, you can also analyze your data using both common and more advanced statistical methods. Note that it may be more complicated to install Python compared to Matlab, for instance. However, there are scientifically focused distributions that has a lot of the libraries that you will want to use. We will cover two, of these Python distributions, in the next section.
Here are some examples of Python distributions that will come with Python packages and Interactive Development Environments (IDEs):
There are many useful Python packages to use. On this site the main applications of this programming language are carrying out descriptive statistics, data visualization, data collection (e.g., scraping, programming of Psychology experiments), and data analysis. Thus, this section will be divided into tutorials with this as the main focus.
Installing, Using, and Updating Python Packages
First, there are some more general Python tutorials that cover more basic concepts such as how you install, use, and update Python packages using pip, pipx, and conda:
- How to install, use, and update Python packages using pip or conda
- Pipx: how to install and use Python packages in virtual environments (directly)
Second, sometimes when you’re installing, or upgrading, Python packages using pip you will notice that pip needs an upgrade. Thus, there’s a post on how to upgrade pip.
Reading a File in Python
Most of the Python tutorials, on this site, is focused on how to use Pandas to import data. That is, these Pandas tutorials focus on how to read files in formats such as CSV, Excel, SPSS, and JSON. However, using Python’s open() function it is, of course, possible to read files (e.g., .text files) in Python without loading, or installing, any libraries:
In some cases, the data we work with is stored in Excel (xlsx) files. There’s a recent guide on this blog about reading xlsx files in Python using the openpyxl module. In that post, you will learn how to read an Excel file as well as reading multiple files.
Renaming a File
Now, sometimes you have a large number of files that need to have their names changed. Luckily, renaming a file (or many files) is something you can do with Python. To rename a file with Python you just import the os module and use the rename() method.
Now, you will also find some simpler math-related Python tutorials on this site.
Python Absolute Value
For instance, in the post about how to get absolute value in Python with abs() and Pandas, you will learn how to do exactly that, get the absolute values of numbers.
How to Work with Jupyter Notebook
In this subsection, you will find all the tutorials related to working with Jupyter notebooks. Right now, the focus is on how to convert HTML to Jupyter notebooks in one post. However, there is also a post on how to use Binder, git, and Jupyter notebooks for reproducible research. In that post, you will learn how to work with Binder to create a reproducible environment. Moreover, you will learn how to use git (which is a requirement to create a Binder) to get a Jupyter notebook that is runnable online, in a browser.
Python Interactive Development Environments (IDES)
If you are programming in Python you may want to use a Python IDE. There are, of course, plenty of choices and here you will find articles describing, and comparing, different IDEs to make it easier for you to find the best Python IDE for your purpose.
- Read the post comparing Pycharm vs. Spyder to see if one of these is the best IDE for your purpose.
- If you are coming from MATLAB you may want to take a look at the Spyder IDE, which is a great IDE for scientific use.
- Finally, if you are an R statistical environment user you may want to have a look at the post looking at comparing Spyder and Rodeo. Both of these may be the best Python IDE if you like RStudio.
Data Collection using Python Tutorials
In the behavioral sciences (e.g., Psychology, Neuroscience, Economics) data is often collected using computerized tasks. For instance, one simple, and commonly used, psychology task is the Flanker task. There are, of course, also other ways to collect data such as scraping keywords from scientific journals, or information from HTML tables (e.g., on Wikipedia). This site hosts a range of tutorials with a focus on using programming, mainly in Python, for data collection.
Data Manipulation, Descriptive Statistics, & Data Visualization
In this section, there are links to different tutorials found on this site. These are divided into different sections (e.g., data manipulation, descriptive statistics, and data visualization tutorial). The tutorials are, in general, focused on packages such as Pandas, NumPy, Matplotlib, Statsmodels, and Seaborn.
Python Pandas Tutorials
In this section, you will find the link to the page containing all the Pandas tutorials on this site. Note, the link is in the final paragraph of this section.
Pandas is a very easy-to-use open-source Python package that will provide high-performance, data structures, and descriptive data analysis as well as data visualization tools. If you are familiar with R statistical programming environment Pandas will be easy to learn.
If needed, here are the links to the Pandas dataframe tutorials. In these tutorials, you will learn how to group data using Pandas groupby(), take random samples of a dataframe, removing columns, do descriptive statistics, and many more.
Data Visualization in Python Tutorials
In this section, you will briefly learn about the packages that enable data visuzulation in Python. Naturally, being a very popular programming language, there are a plethora of different packages for visualizing data in Python. Thus, the list below is not complete but covers the ones that are used in the data visualization in Python tutorials on this site. First, here are all the Python data visualization tutorials.
- Matplotlib is a data visualization library that is quite easy to use and the plots are very modifiable.
- Seaborn is based on Matplotlib and is easier to use.
Parametric Statistics in Python Tutorials
In this section, you will briefly learn about the packages that you can carry out data analysis in Python with. Of course, as in the case with data visualization in Python, here are a lot of different packages for doing data analysis in Python. Now, the most commonly used ones on this site are the following Python data analysis packages.
- On the page data analysis in Python you will find links to all the statistics related tutorials on this site.