Python for Data Analyst

How to get odd and even numbers from a list in Python

Hits: 16  How to get odd and even numbers from a list in Python In this coding example, we learn how to find odd and even numbers from a list using Python program. Code Example:   Outcomes:   Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects …

Python Example – The most simplest python program to create a QR code

Hits: 8 The most simplest python program to create a QR code In this coding example,  we showed how to generate a QR code using Python package called pyqrcode. It is a very simple example.     Result   Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio …

Understanding ROC Curves with Python

Hits: 5  Understanding ROC Curves with Python In the current age where Data Science / AI is booming, it is important to understand how Machine Learning is used in the industry to solve complex business problems. In order to select which Machine Learning model should be used in production, a selection metric is chosen upon …

How to do Cross Validation and Grid Search for Model Selection in Python

Hits: 2 How to do Cross Validation and Grid Search for Model Selection in Python Introduction A typical machine learning process involves training different models on the dataset and selecting the one with best performance. However, evaluating the performance of algorithm is not always a straight forward task. There are several factors that can help …

How to Implement LDA in Python with Scikit-Learn

Hits: 2  How to Implement LDA in Python with Scikit-Learn In our previous article Implementing PCA in Python with Scikit-Learn, we studied how we can reduce dimensionality of the feature set using PCA. In this article we will study another very important dimensionality reduction technique: linear discriminant analysis (or LDA). But first let’s briefly discuss how PCA and …

Loops in Python for Business Analyst

Hits: 3 Loops in Python for Business Analyst Choosing the Right Loop Construct Python offers a variety of constructs to do loops. This article presents them and gives advice on their specific usage. Furthermore, we will also have a look at the performance of each looping construct in your Python code. It might be surprising …

How to List Files in a Directory using Python

Hits: 9 How to List Files in a Directory using Python Using os.walk() The os module contains a long list of methods that deal with the filesystem, and the operating system. One of them is walk(), which generates the filenames in a directory tree by walking the tree either top-down or bottom-up (with top-down being the default setting). os.walk() returns …

How to do Parallel Processing in Python

Hits: 1 How to do Parallel Processing in Python Introduction When you start a program on your machine it runs in its own “bubble” which is completely separate from other programs that are active at the same time. This “bubble” is called a process, and comprises everything which is needed to manage this program call. For …

How to Read a File Line-by-Line in Python

Hits: 0 Google –> SETScholars. How to Read a File Line-by-Line in Python Introduction Over the course of my working life I have had the opportunity to use many programming concepts and technologies to do countless things. Some of these things involve relatively low-value fruits of my labor, such as automating the error prone or …

What is Command Line Arguments in Python

Hits: 0 What is Command Line Arguments in Python Overview With Python being such a popular programming language, as well as having support for most operating systems, it’s become widely used to create command line tools for many purposes. These tools can range from simple CLI apps to those that are more complex, like AWS’ awscli tool. …

Data Viz in Python – Stacked Percentage Bar Plot In MatPlotLib

Hits: 7 Stacked Percentage Bar Plot In MatPlotLib Preliminaries %matplotlib inline import pandas as pd import matplotlib.pyplot as plt Create dataframe raw_data = {‘first_name’: [‘Jason’, ‘Molly’, ‘Tina’, ‘Jake’, ‘Amy’], ‘pre_score’: [4, 24, 31, 2, 3], ‘mid_score’: [25, 94, 57, 62, 70], ‘post_score’: [5, 43, 23, 23, 51]} df = pd.DataFrame(raw_data, columns = [‘first_name’, ‘pre_score’, ‘mid_score’, …

Data Viz in Python – Pie Chart In MatPlotLib

Hits: 3 Pie Chart In MatPlotLib Preliminaries %matplotlib inline import pandas as pd import matplotlib.pyplot as plt Create dataframe raw_data = {‘officer_name’: [‘Jason’, ‘Molly’, ‘Tina’, ‘Jake’, ‘Amy’], ‘jan_arrests’: [4, 24, 31, 2, 3], ‘feb_arrests’: [25, 94, 57, 62, 70], ‘march_arrests’: [5, 43, 23, 23, 51]} df = pd.DataFrame(raw_data, columns = [‘officer_name’, ‘jan_arrests’, ‘feb_arrests’, ‘march_arrests’]) df …

Data Viz in Python – Group Bar Plot In MatPlotLib

Hits: 5 Group Bar Plot In MatPlotLib Preliminaries %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import numpy as np Create dataframe raw_data = {‘first_name’: [‘Jason’, ‘Molly’, ‘Tina’, ‘Jake’, ‘Amy’], ‘pre_score’: [4, 24, 31, 2, 3], ‘mid_score’: [25, 94, 57, 62, 70], ‘post_score’: [5, 43, 23, 23, 51]} df = pd.DataFrame(raw_data, columns = …

Data Viz in Python – Creating Scatterplots With Seaborn

Hits: 3 Creating Scatterplots With Seaborn Preliminaries import pandas as pd %matplotlib inline import random import matplotlib.pyplot as plt import seaborn as sns Create data /* Create empty dataframe */ df = pd.DataFrame() /* Add columns */ df[‘x’] = random.sample(range(1, 1000), 5) df[‘y’] = random.sample(range(1, 1000), 5) df[‘z’] = [1,0,0,1,0] df[‘k’] = [‘male’,’male’,’male’,’female’,’female’] /* View …

Data Viz in Python – Creating A Time Series Plot With Seaborn And pandas

Hits: 6 Creating A Time Series Plot With Seaborn And pandas Preliminaries import pandas as pd %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns data = {‘date’: [‘2014-05-01 18:47:05.069722’, ‘2014-05-01 18:47:05.119994’, ‘2014-05-02 18:47:05.178768’, ‘2014-05-02 18:47:05.230071’, ‘2014-05-02 18:47:05.230071’, ‘2014-05-02 18:47:05.280592’, ‘2014-05-03 18:47:05.332662’, ‘2014-05-03 18:47:05.385109’, ‘2014-05-04 18:47:05.436523’, ‘2014-05-04 18:47:05.486877’], ‘deaths_regiment_1’: [34, 43, 14, 15, 15, …