Tag Archives: python for beginners

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 …

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 do K-Means Clustering with Scikit-Learn in Python

Hits: 5 How to do K-Means Clustering with Scikit-Learn in Python Introduction K-means clustering is one of the most widely used unsupervised machine learning algorithms that forms clusters of data based on the similarity between data instances. For this particular algorithm to work, the number of clusters has to be defined beforehand. The K in …

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 …

Python Exception Handling

Hits: 3  Python Exception Handling This tutorial will give an introduction to what Python exceptions are, the most common types of exceptions, and how to handle raised exceptions with the try and except clauses. What is a Python Exception? A Python exception is a construct used to signal an important event, usually an error, that occurs when executing a …

How to Save and Restore scikit learn Models

Hits: 0  How to Save and Restore scikit learn Models On many occasions, while working with the scikit-learn library, you’ll need to save your prediction models to file, and then restore them in order to reuse your previous work to: test your model on new data, compare multiple models, or anything else. This saving procedure is also …

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. …

Reading and Writing CSV Files in Python

Hits: 1 Reading and Writing CSV Files in Python What is a CSV File? A CSV (Comma Separated Values) file is a file that uses a certain formatting for storing data. This file format organizes information, containing one record per line, with each field (column) separated by a delimiter. The delimiter most commonly used is …

Data Wrangling in Python – How to Use List Comprehensions With pandas

Hits: 7 Using List Comprehensions With pandas Preliminaries /* Import modules */ import pandas as pd /* Set ipython’s max row display */ pd.set_option(‘display.max_row’, 1000) /* Set iPython’s max column width to 50 */ pd.set_option(‘display.max_columns’, 50) Create an example dataframe data = {‘name’: [‘Jason’, ‘Molly’, ‘Tina’, ‘Jake’, ‘Amy’], ‘year’: [2012, 2012, 2013, 2014, 2014], ‘reports’: …

Data Wrangling in Python – How to Select Rows With Multiple Filters

Hits: 4 Select Rows With Multiple Filters /* import pandas as pd */ import pandas as pd /* Create an example dataframe */ data = {‘name’: [‘A’, ‘B’, ‘C’, ‘D’, ‘E’], ‘score’: [1,2,3,4,5]} df = pd.DataFrame(data) df name score 0 A 1 1 B 2 2 C 3 3 D 4 4 E 5 /* …

Data Wrangling in Python – How to Select Rows When Columns Contain Certain Values

Hits: 6 Select Rows When Columns Contain Certain Values Preliminaries /* Import modules */ import pandas as pd /* Set ipython’s max row display */ pd.set_option(‘display.max_row’, 1000) /* Set iPython’s max column width to 50 */ pd.set_option(‘display.max_columns’, 50) Create an example dataframe /* Create an example dataframe */ data = {‘name’: [‘Jason’, ‘Molly’, ‘Tina’, ‘Jake’, …