Python Tutorial: Python for R Users Introduction

preview_player
Показать описание

---

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.

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.

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

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

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.

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

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.

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.

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

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.

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.

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 to each other are automatically concatenated. This can be useful if you want to break up a long string across multiple lines of code.

Now it's time to write some Python code.
Рекомендации по теме