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…
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
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.
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.
lambda args : exp
where args represents arguments and exp is the expression. The expression is executed and the result is returned. …
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 is an elegant way of creating a new list from an existing list. Let us understand Python’s list comprehension using examples.
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)…
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:
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.
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:
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).
Before going upgrading, we check the existing version by running the following command in the terminal:
$ cat /etc/lsb-release
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:
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. …
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 numpy as np
We use a random seed as follows:
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)
Now, these two functions are executed in parallel as follows:
if __name__ == '__main__':
data = np.array([1,2,3,4,5]) …