Python Pandas DataFrame tutorial for beginners
Python Pandas DataFrame tutorial for beginners

This is a tutorial on Python Pandas DataFrame for absolute beginners. Pandas is a fast, powerful, flexible, and easy to use open-source data analysis and manipulation tool, built on top of the Python programming language. In this tutorial, we will use the Customers.csv file which can be downloaded from here.

Here, we will learn about the following: read_csv() method, shape attribute of DataFrame, head() and tail() methods, info() method, columns and index attributes of DataFrame, dtypes, subsetting of rows and columns, drop, loc, iloc, aggregate function, and groupby.

At first, we import Pandas using the import statement.

# Import Pandas with an alias pd 
import pandas as…


Solving linear programming problems (LPPs) using PuLP and Python
Solving linear programming problems (LPPs) using PuLP and Python

In this tutorial, we will learn how to solve linear programming problems (LPPs) using PuLP and Python. At first, we learn how to install PuLP. If PuLP is already not installed in your system, then you can use the following commands to install it.

For Ubuntu, run the following command in the terminal:

pip install pulp

Lambda and map() functions in Python
Lambda and map() functions in Python

This is a tutorial on lambda and map() functions in Python. Here, we will consider Python3. We start with the lambda function, and then we discuss the map() function in Python. This tutorial will help to understand the concepts of lambda and map() functions in Python.

Lambda function

At first, we will learn about the basics of the lambda function in Python. A lambda function is a simple one-line function. It doesn’t use def or return keywords. These are implicit here.

Syntax:

lambda args : exp

where args represents arguments and exp is the expression. The expression is executed and the result is returned. …


List and dictionary comprehensions in Python
List and dictionary comprehensions in Python

In this tutorial, we will learn about the list and dictionary comprehensions in Python. We will begin with list comprehension and then we discuss dictionary comprehension.

List Comprehension

List comprehension is an elegant way of creating a new list from an existing list. Let us understand Python’s list comprehension using examples.

Example 1:

At first, we create dummy data. It is a list L of the first ten natural numbers. Using list comprehension, we create another list E which contains the even numbers from L.

L = [1,2,3,4,5,6,7,8,9,10] # dummy dataE = [num for num in L if num%2 == 0]print(E)

Descriptive Statistics using Python Pandas
Descriptive Statistics using Python Pandas

In this tutorial, we will learn how to compute descriptive statistics using Python’s Pandas library. We use a well-known dataset in this tutorial. This dataset consists of several medical predictor (independent) variables and one target (dependent) variable, Outcome. Independent variables include the number of pregnancies the patient has had, their BMI, insulin level, age, and so on.

The columns of this dataset are as follows:

  1. Pregnancies — Number of times pregnant
  2. GlucosePlasma — glucose concentration 2 hours in an oral glucose tolerance test
  3. Blood Pressure — Diastolic blood pressure (mm Hg)
  4. SkinThickness — Triceps skin-fold thickness (mm)
  5. Insulin — Two hours of serum insulin (mu…


Image for post
Image for post

In this tutorial, we will learn how to write a model for linear programming problems (LPPs) using Python API and solve the model using IBM Decision Optimization CPLEX (DOcplex) Modeling for Python on your computer with IBM ILOG CPLEX Optimization Studio. Here, we will assume that Python3 and IBM ILOG CPLEX Optimization Studio v12.8 or later are installed on your machine.

Example problem

Consider a chocolate manufacturing company that produces only two types of chocolate — A and B. Both the chocolates require Milk and Choco only. To manufacture each unit of A and B, the following quantities are required:

  • Each unit of A requires 1 unit of Milk and 3 units of…

Image for post
Image for post
Desktop image of Ubuntu 20.04 LTS (Focal Fossa)

Canonical has released Ubuntu 20.04 LTS (Focal Fossa) on 23rd April 2020. It is a long-term support version. In this tutorial, we will learn how to upgrade Ubuntu 18.04 LTS to Ubuntu 20.04 LTS. We can also download Ubuntu 20.04 LTS (Focal Fossa) from the official webpage and we can do a fresh installation. The objective of this tutorial is to upgrade the existing Ubuntu 18.04 LTS (Bionic Beaver) to the latest Ubuntu 20.04 LTS (Focal Fossa).

Step:1

Before going upgrading, we check the existing version by running the following command in the terminal:

$ cat /etc/lsb-release


Analyzing Pima-Indians-Diabetes-Data using Python
Analyzing Pima-Indians-Diabetes-Data using Python

In this tutorial, we will learn how to analyze Pima-Indians-Diabetes-Data (in .csv format) using Python’s Pandas. This dataset consists of several medical predictor (independent) variables and one target (dependent) variable, Outcome. Independent variables include the number of pregnancies the patient has had, their BMI, insulin level, age, and so on.

The columns of this datasets are as follows:

  1. Pregnancies — Number of times pregnant
  2. GlucosePlasma — glucose concentration 2 hours in an oral glucose tolerance test
  3. Blood Pressure — Diastolic blood pressure (mm Hg)
  4. SkinThickness — Triceps skin-fold thickness (mm)
  5. Insulin — Two hours of serum insulin (mu U/ml)
  6. BMI — Body mass index (weight in kg/(height in…


Image for post
Image for post

I am now living in Brno, Czech Republic, with my wife. We are from India. We are here at Brno city since 15th August 2019. I am working as a Postdoctoral researcher in the Faculty of Informatics, Masaryk University. Brno is a great city to live. Here, you will find many international students from all over the world. Although the cost of living at Brno is not so high, the monthly rent of a private apartment for a family is slightly high. The monthly rent of a private apartment (around 50 square meters) at Brno city is approximately CZK 18k to 20k including all utilities. There are many grocery supermarkets available in the city such as Albert, Tesco, Bila, Lidl, etc. We stay near to the Faculty of Informatics, Masaryk University. …


Image for post
Image for post

In this tutorial, we will learn how to achieve multiprocessing in Python. We will use Python’s multiprocessing package which supports process-based parallelism.

At first, we import the required packages.

import multiprocessing as mp
import random
import string
import numpy as np

We use a random seed as follows:

random.seed(123)

Now, we define an output queue.

output = mp.Queue()

We also define two example functions.

# First example function
def addition(data, i, output):
sum = np.sum(data)
output.put((i, sum))
# Second example function
def multiplication(data, i, output):
prod = np.prod(data)
output.put((i, prod))

Now, these two functions are executed in parallel as follows:

if __name__ == '__main__':
data = np.array([1,2,3,4,5])

About

Dr. Soumen Atta, Ph.D.

Assistant Professor at Indian Institute of Information Technology (IIIT) Vadodara, India, and Postdoctoral researcher at Masaryk University, Czech Republic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store