What is Python and How to Get Started?

Python is an interpreted, general-purpose programming language. For interpreted language, it means that the Python codes are converted into bytecode, which is executed by the Python virtual machine. You can simply use the basic Python interpreter to run your code with the command line. For instance, you type “print(‘Hello New York’)” and hit Enter. It will show “Hello … Read more

How to Conduct Correlation Analysis in Python

Correlation is a statistical measure of the relationship between two variables, X and Y. This tutorial how to use Scipy, Numpy, and Pandas to do Pearson correlation analysis. Finally, it also shows how you can plot correlation in Python using seaborn. Method 1: Use scipy to calculate correlation in Python scipy.stats.pearsonr(x, y) Method 2: Use … Read more

Tutorial of Data Visualization Using Python

Introduction This tutorial shows how to plot line charts, bar charts, and scatter plots in Python. The major packages being used include Pandas, Matplotlib, and Seaborn. Note that, Pandas plot functions and Seaborn build on the top of Matplotlib, and thus you can use some functions from Matplotlib. In some situations, I found it easier … Read more

How to Modify, Add, Delete Dataframe Values in Python

This tutorial will show you how to modify, add, delete values in a dataframe in Python with examples. How to Modify a Single Value in Dataframe Let’s first create a dataframe from on a dictionary and then print it out. Brand Count 0 Tesla 3 1 Ford 4 We can then change a value within … Read more

How to Select or Subset Dataframe Columns in Python

The tutorial shows how to select columns in a dataframe in Python. method 1: df[‘column_name’] method 2: df.column_name method 3: df.loc[:, ‘column_name’] method 4: df.iloc[:, column_number] Example for method 1 The following uses df[‘column_name’] to subset a column of data. In particular, it subsets the column of ‘Location.’ The following shows the original dataframe and … Read more

What is Dataframe in Python?

This tutorial explains what a dataframe is in Python. Further, I will show how to define a dataframe using Pandas with examples. Finally, I will show how to define a dataframe from Pandas.series. Introduction of Dataframe Dataframe is two-dimensional, size-mutable, potentially heterogeneous tabular data. For instance, below is a dataframe of Microsoft stock price. (Regarding … Read more

How to Write For Loop in Python (Examples)

This tutorial includes 3 examples showing how to write for loop in Python. Example 1 of for loop in Python The following creates a list called cars, and we can then use for loop to print out each item in the list. The following is the output, which includes a complete list format and for … Read more

Python Tuples

What is tuple in Python? Tuple is one of 4 built-in data types in Python. The other 3 are Dictionary, Set, and List, all of which can be used to store a collection of elements/items, The following lists a few key characteristics of Tuple. The elements in a Tuple are ordered. The elements in a Tuple … Read more

Python Sets

This tutorial defines what Python sets are, how to measure the size of sets in Python, how to add or remove elements in a set, how to loop through a set. I will also explain why sets are not subscriptable in Python.

Python Lists

What is list in Python? Python Lists are an ordered collection of items within square brackets []. How to create a list in Python We use the square brackets ([]) to create a list. We can create an empty list. The following example shows how you can create a list of some actual items in … Read more