First, we will rename a single file in 4 easy steps. After that, we will learn how to rename multiple files using Python 3. To be able to change the name of multiple files using Python can come in handy. For example, if we have a bunch of data files (e.g., .csv files) with long, or strange names, we may want to rename them to make working with them easier later in our projects (e.g., when loading the CSV files into a Pandas dataframe).
Author: Erik Marsja
PhD in Psychology, Linköping University. Main interest is experimental and cognitive psychology. Enjoy programming in Python and R.
In this short post, we will learn how to save Seaborn plots to a range of different file formats. More specifically, we will learn how to use the plt.savefig method save plots made with Seaborn to:
- Portable Network Graphics (PNG)
- Portable Document Format (PDF)
- Encapsulated Postscript (EPS)
- Tagged Image File Format (TIFF)
- Scalable Vector Graphics (SVG)
In this post, we will learn how to use Pandas drop_duplicates() to remove duplicate records and combinations of columns from a Pandas dataframe. That is, we will delete duplicate data and only keep the unique values.
This Pandas tutorial will cover the following; what’s needed to follow the tutorial, importing Pandas, and how to create a dataframe fro a dictionary. After this, we will get into how to use Pandas drop_duplicates() to drop duplicate rows and duplicate columns.
In this remove a column in R tutorial, we are going to work with dplyr to delete a column. Here, we are going to learn how to remove columns in R using the
select() function. Specifically, we are going to remove columns by name and by index.
Finally, we will also learn how to remove columns from R dataframes that start with a letter, or a word ends with a letter, or word, or contains a character (like the underscore).
In this tutorial, we are going to learn how to read a file in Python 3. After we have learned how to open a file in Python, we are going to learn how to write to the file and save it again. In previous posts, we have learned how to open a range of different files using Python. For instance, we have learned how to open JSON, CSV, Excel, and HTML files using Pandas, and the json library. Here, however, we are going to open plain files (.txt) in Python.
In this post, we will learn how to use Pandas get_dummies() method to create dummy variables in Python. Dummy variables (or binary/indicator variables) are often used in statistical analyses as well as in more simple descriptive statistics. Towards the end of the post, there’s a link to a Jupyter Notebook containing all Pandas get_dummies() examples.
Dummy Coding for Regression Analysis
One statistical analysis in which we may need to create dummy variables in regression analysis. In fact, regression analysis requires numerical variables and this means that when we, whether doing research or just analyzing data, wishes to include a categorical variable in a regression model, supplementary steps are required to make the results interpretable.
In this post, we will learn how to carry out descriptive statistics in R. After we have learned how to do this, we will learn how to create a nice latex table and how to save the summary statistics to a .csv file.
Why Descriptive Statistics?
Carrying out descriptive statistics, also known as summary statistics, is a very good starting point for most statistical analyses. It is, furthermore, a very good way to summarize and communicate information about the data we have collected.
In this short tutorial, we will learn how to change the figure size of Seaborn plots. For many reasons, we may need to either increase the size or decrease the size, of our plots created with Seaborn.
When do We Need to Change the Size of a Plot?
One example, for instance, when we might want to change the size of a plot could be when we are going to communicate the results from our data analysis. In this case, we may compile the descriptive statistics, data visualization, and results from data analysis into a report, or manuscript for scientific publication.
Here, we may need to change the size so it fits the way we want to communicate our results. Note, for scientific publication (or printing, in general) we may want to also save the figures as high-resolution images.
In this post we are going to learn 1) how to read SPSS (.sav) files in R, and 2) how to write to SPSS (.sav) files using R. More specifically, here we are going to work with the following two R packages haven (from the Tidyverse) and foreign to:
- Read a .sav file into an R dataframe
- Writing an R dataframe to a .sav file