Programming Articles

Page 913 of 2547

Statistical Thinking in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 467 Views

Statistical thinking is fundamental for machine learning and AI. Since Python is the language of choice for these technologies, we will explore how to write Python programs that incorporate statistical analysis. In this article, we will create graphs and charts using various Python modules to analyze data quickly and derive insights through visualization. Data Preparation We'll use a dataset containing information about various seeds. This dataset is available on Kaggle and has eight columns that we'll use to create different types of charts for comparing seed features. The program below loads the dataset and displays sample rows. ...

Read More

Predicting Customer Churn in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 699 Views

Customer churn refers to customers leaving a business. Predicting churn helps businesses identify at-risk customers and take preventive actions. This article demonstrates how to build a machine learning model to predict telecom customer churn using Python. Dataset Overview We'll use the Telecom Customer Churn dataset which contains customer information like demographics, services, and churn status. Let's load and examine the data ? import pandas as pd # Loading the Telco-Customer-Churn.csv dataset # Dataset available at: https://www.kaggle.com/blastchar/telco-customer-churn data = pd.read_csv('Telecom_customers.csv') print("Dataset shape:", data.shape) print("First few rows:") print(data.head()) The output shows the dataset structure ? ...

Read More

Fraud Detection in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 3K+ Views

Fraud detection is a critical application of machine learning where we analyze historical transaction data to predict whether a new transaction is fraudulent. In this tutorial, we'll build a fraud detection system using credit card transaction data, applying a decision tree classifier to identify suspicious transactions. Preparing the Data We start by loading and exploring our dataset to understand its structure and features. The credit card fraud dataset contains anonymized features (V1-V28) obtained through PCA transformation, along with Time, Amount, and Class columns ? import pandas as pd # Load the credit card dataset # ...

Read More

Fast XML parsing using Expat in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

Python's xml.parsers.expat module provides fast XML parsing using the Expat library. It is a non-validating XML parser that creates an XML parser object and captures XML elements through various handler functions. This event-driven approach is memory-efficient and suitable for processing large XML files. How Expat Parser Works The Expat parser uses three main handler functions ? StartElementHandler − Called when an opening tag is encountered EndElementHandler − Called when a closing tag is encountered CharacterDataHandler − Called when character data between tags is found Example Here's how to parse XML data using Expat ...

Read More

Windows registry access using Python (winreg)

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 6K+ Views

Python provides excellent support for OS-level programming through its extensive module library. The winreg module allows Python programs to access and manipulate the Windows registry, which stores configuration settings and system information. The Windows registry is organized in a hierarchical structure with keys and values. Python's winreg module provides functions to connect to, read from, and write to registry keys. Basic Registry Access First, import the winreg module and establish a connection to the registry ? import winreg # Connect to the registry access_registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) # Open a specific key access_key ...

Read More

Python - Filter the negative values from given dictionary

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 608 Views

As part of data analysis, we often encounter scenarios where we need to filter out negative values from a dictionary. Python provides several approaches to accomplish this task efficiently. Below are two common methods using different programming constructs. Using Dictionary Comprehension Dictionary comprehension provides a clean and readable way to filter negative values. We iterate through each key-value pair and include only those with non-negative values ≥ Example dict_1 = {'x': 10, 'y': 20, 'z': -30, 'p': -0.5, 'q': 50} print("Given Dictionary:", dict_1) filtered_dict = {key: value for key, value in dict_1.items() if ...

Read More

Python - Filter even values from a list

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

As part of data analysis, we often need to filter values from a list meeting certain criteria. In this article, we'll see how to filter out only the even values from a list. To identify even numbers, we check if a number is divisible by 2 (remainder is zero when divided by 2). Python provides several approaches to filter even values from a list. Using for Loop This is the simplest way to iterate through each element and check for divisibility by 2 ? numbers = [33, 35, 36, 39, 40, 42] even_numbers = ...

Read More

All possible permutations of N lists in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

When we have multiple lists and need to combine each element from one list with each element from another list, we're creating what's called a Cartesian product (not permutations). Python provides several approaches to achieve this combination. Using List Comprehension This straightforward approach uses nested list comprehension to create all possible combinations. The outer loop iterates through the first list, while the inner loop iterates through the second list ? Example A = [5, 8] B = [10, 15, 20] print("The given lists:", A, B) combinations = [[m, n] for m in A for ...

Read More

Python - Column summation of tuples

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 345 Views

Python has extensive availability of various libraries and functions which make it so popular for data analysis. We may get a need to sum the values in a single column for a group of tuples for our analysis. So in this program we are adding all the values present at the same position or same column in a series of tuples. Column summation involves adding corresponding elements from tuples at the same positions. For example, if we have tuples (3, 92) and (25, 62), the column summation would be (28, 154). Using List Comprehension and zip() Using ...

Read More

max() and min() in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

Finding maximum and minimum values from a given list of values is a very common need in data processing programs. Python provides built-in max() and min() functions that handle both numbers and strings efficiently. Syntax max(iterable, *[, key, default]) min(iterable, *[, key, default]) Using max() and min() with Numeric Values Both functions work with integers, floats, and mixed numeric types to find the maximum and minimum values ? numbers = [10, 15, 25.5, 3, 2, 9/5, 40, 70] print("Maximum number is:", max(numbers)) print("Minimum number is:", min(numbers)) Maximum number is: ...

Read More
Showing 9121–9130 of 25,466 articles
« Prev 1 911 912 913 914 915 2547 Next »
Advertisements