Six Ways to Reverse Pandas dataframe

In this post we will learn how to reverse Pandas dataframe. We start by changing the first column with the last column and continue with reversing the order completely. After we have learned how to swap columns in the dataframe and reverse the order by the columns, we continue by reversing the order of the rows. That is, pandas dataframe can be reversed such that the last column becomes the first or such that the last row becomes the first.

Continue reading →

Why Spyder is the Best Python IDE for Science

Spyder is the best Python IDE that I have tested so far for doing data analysis, but also for plain programming. In this post I will start to briefly describe the IDE. Following the description of this top IDE the text will continue with a discussion of my favorite features. You will also find out how to install Spyder on Ubuntu 14.04 and at the end of the post you will find a comparison of Rodeo (a newer IDE more RStudio like) and Spyder.

When I started programming in Python I used IDLE which is the IDE that you will get with your installation of Python (e.g., on Windows computers). I actually used IDLE IDE for some time. It was not until I started to learn R and found  RStudio IDE. I thought that RStudio was great (and it still is!). However, after learning R and RStudio I started to look for a better Python IDE.

Continue reading →

Every Psychologist Should Learn Programming

The aim of this post is to show you why you, as a psychology student or researcher (or any other kind researcher or student) should learn to program. The post is structured as follows. First I start by discussing why you should learn programming and then give some examples when programming skills are useful. I continue to suggest two programming languages that I think all Psychology students and researchers should learn.

Continue reading →

R Resources for Psychologists

Good resources for learning R as a Psychologist are hard to find. By that I mean that there are so many great sites and blogs around the internet to learn R. Thus, it may be hard to find learning resources that targets Psychology researchers.

Recently I wrote about four good R books targeted for Psychology students and researchers (i.e., R books for Psychologists). There are, however, of course other good resources for Psychological researchers to learn R programming.

Therefore, this post will list some of the best blogs and sites to learn R.  The post will be divided into two categories; general and Psychology focused R sites and blogs. For those who are not familiar with R I will start with a brief introduction on what R is (if you know R already; click here to skip to the links).

What is R?

If you are new to R you might wonder what R is? R is a free and open source programming language and environment. Data analysis in R is carried out by writing scripts and functions. Finally, R is a complete, interactive, and object-oriented language.

"R

In R statistical environment, you are able to carry out a variety of statistical and graphical techniques. For instance, linear and nonlinear modeling, classical statistical tests, time-series analysis, classification, and many more can be carried using both frequentist and Bayesian paradigms.

If you are new to R, you may want to start with R commander. This will provide you with a menu making the process of  learning R a bit easier at the beginning. R can be downloaded here: The Comprehensive R Archive Network.

R Resources

One of the main things that I like with R is the broad and helpful community. This also means that there are many good resources for learning the language. Continue reading →

Rodeo - RStudio for Python - a good IDE for doing Data Science

Installing Rodeo IDE on Linux

I recently wrote a post on the RStudio like Python IDE Rodeo (RStudio-like Python IDEs – Rodeo and Spyder). In that post, I installed and tested Rodeo 0.44. However, Rodeo 1.0 was released in October. Rodeo 1.0 cannot be installed using Pip. Therefore, I wrote a bash script for downloading and unzipping Rodeo. Note, the script below will now install Rodeo 2 and is tested on my Ubuntu 16.04 machines.

What is Rodeo?

Rodeo is, as previously mentioned, a Python IDE very similar to RStudio. It is intended to use for Data Science. If you are coming from R and plan to add Python to your stack, Rodeo is probably going to be very familiar to you. Given that you have used RStudio, that is. I would still say that Spyder may be a better IDE for doing Data Science in Python. Why? Because, up to date, there are plenty of more features in Spyder compared Rodeo. Update: now you will get a .deb file when using wget (see below). Thus, we can use dpkg to install the Rodeo IDE.

Installing Rodeo

#!/bin/sh

wget -O rodeo.deb https://www.yhat.com/products/rodeo/downloads/linux_64 

sudo dpkg -i install rodeo.deb

The above code will download the Linux 64 binaries for Rodeo, unzip it into the ‘/usr/local/bin’ directory, and remove the downloaded file. Finally, a symbolic link to the executable is created. As Jo writes in the comments, it seems like Rodeo is released exclusively for 64 bit only – there is no 32 bit Rodeo.

Note, you can just cut & paste the code and paste it into a command window. If you, however, save it as a bash script (i.e., install_rodeo.sh) you need to make it executable; chmod +x install_rodeo.sh. To download and install Rodeo:

sh install_rodeo.sh

I have tested installing Rodeo IDE on Ubuntu 14.04 and 16.04 with the above script. If you don’t have Jupyter and Matplotlib installed it may need to install them also;

pip install matplotlib jupyter

If you need to upgrade pip to the latest version see the following post:

Installing Rodeo on Ubuntu/Debian

If you are using Ubuntu or Debian you can add Yhats repository (source Yhat Downloads):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 33D40BC6
sudo add-apt-repository "deb http://rodeo-deb.yhat.com/ rodeo main"

sudo apt update
sudo apt -y install rodeo

That’s all, now you should know how to easily download and install Rodeo 1.0 on your Linux machine. Please let me know if you need to do more than I described in this post.