Get startedGet started for free

Introduction

1. Introduction

Hi! My name is Daniel Chen and I will be your instructor for this course on Python for R users. Python and R are two of the most popular languages used in Statistics, Data Science and Machine Learning. In this course, we'll show you the similarities and differences between R and Python so you can utilize the strengths of each language and pick the best tool for your specific needs.

2. The basics

We will start with assigning values to variables, working with different data types, and the two most commonly used built-in data structures in python: lists and dictionaries.

3. Programming fundamentals

We will then move on to conditional statements, loops, and functions.

4. Pandas

We will also explore the pandas library to see how we can subset, view, and manipulate data that is stored in rectangular format.

5. Plotting

Next, the course will go over the 3 most popular ways of plotting data in Python: using pandas directly, and then using the matplotlib and seaborn libraries.

6. Putting it all together

Finally, we'll put everything together by looking at the NYC Flights 2013 dataset to get some insight into flight delays.

7. Python data types

Let's begin by looking at the basic data types. Similar to R, you have strings, integers, floating point numbers and boolean values in Python. Although, the main difference is the syntax for boolean values, R has the true and false values in all caps, whereas Python only capitalizes the first letter.

8. Assignment

Just like in R, the values on the right hand side of the equal sign are assigned to the variable specified to the left of the equal sign. You do not need to declare them in advance or specify a type. Although unlike R, the equal sign is the only way to assign values to variables.

9. Print statements

When scripting in Python, it is necessary to explicitly use the print() function to print the objects.

10. What's your data type?

It's important to know the data type of the object you are working with. In R this is done with the class() function. In Python, the type() function returns the type of the object.

11. Operators

Knowing the type of an object is important because you will get different behavior from different operations depending on the type. For example if you add 2 numeric values, you get the sum of the values. You can't perform mathematical operations with non-numeric values in R.

12. Operators

In Python, when you add 2 strings using the + operator, the two strings are concatenated. A string multiplied by an integer, n, will repeat the string n times. Finally, strings that are placed next each other are automatically concatenated. This can be useful if you want to breakup a long string across multiple lines of code.

13. Let's practice!

Now it's time to write some Python code.