Python Articles

Page 658 of 855

Python - Plotting Radar charts in excel sheet using XlsxWriter module

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 313 Views

A radar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart where three or more quantitative variables are represented on axes starting from the same point. Python's XlsxWriter module allows you to create radar charts directly in Excel files. Installing XlsxWriter First, install the XlsxWriter module if you haven't already ? pip install XlsxWriter Creating a Radar Chart Here's how to create a radar chart with sample data comparing two batches ? import xlsxwriter # Create a workbook and add a worksheet workbook ...

Read More

Python - Plotting an Excel chart with pattern fills in column using XlsxWriter module

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 264 Views

The XlsxWriter module allows you to create Excel charts with pattern fills in columns, making data visualization more distinctive and professional. Pattern fills help differentiate data series visually, especially when working with monochrome displays or printing. Understanding Pattern Fills Pattern fills apply textures or patterns to chart columns instead of solid colors. Common patterns include 'shingle', 'horizontal_brick', 'vertical_brick', and 'dots'. Each pattern can have foreground and background colors for customization. Example Let's create a column chart comparing different building materials with pattern fills − import xlsxwriter # Create workbook and worksheet workbook = ...

Read More

Python - Plotting an Excel chart with Gradient fills using XlsxWriter module

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 301 Views

XlsxWriter is a Python library for creating Excel files with advanced formatting, including charts with gradient fills. This tutorial shows how to create a column chart with gradient-filled data series. Installing XlsxWriter First, install the required module ? pip install xlsxwriter Creating Excel Chart with Gradient Fills The following example creates a column chart with two data series, each having different gradient colors ? import xlsxwriter # Create a workbook and add a worksheet workbook = xlsxwriter.Workbook('chart_gradient1.xlsx') worksheet = workbook.add_worksheet() # Create a bold format for headers bold = ...

Read More

Python - Number of values greater than K in list

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 908 Views

Counting the number of values greater than a specific threshold K in a list is a common programming task. Python provides several efficient approaches to solve this problem using different techniques. Using a For Loop The traditional approach uses a counter variable and iterates through each element − # Find number of elements > k using for loop numbers = [1, 7, 5, 6, 3, 8] k = 4 print("The list:", numbers) count = 0 for num in numbers: if num > k: ...

Read More

Python - Implementation of Polynomial Regression

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 411 Views

Polynomial Regression is a form of linear regression in which the relationship between the independent variable x and dependent variable y is modeled as an nth degree polynomial. Polynomial regression fits a nonlinear relationship between the value of x and the corresponding conditional mean of y, denoted E(y |x). Unlike simple linear regression that creates a straight line, polynomial regression can capture curved relationships in data by using polynomial terms like x², x³, etc. Creating Sample Data First, let's create some sample data to demonstrate polynomial regression ? import numpy as np import matplotlib.pyplot as ...

Read More

Python - Image Classification using keras

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 440 Views

Image classification is a fundamental computer vision task that categorizes images into predefined classes. Keras provides powerful tools to build convolutional neural networks (CNNs) for this purpose. There are two main approaches ? Training a small network from scratch Fine tuning the top layers of the model using VGG16 Setting Up the Environment First, we import the necessary libraries and define basic parameters ? # Importing all necessary libraries from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D from keras.layers import Activation, Dropout, Flatten, Dense from keras import backend ...

Read More

Python - How and where to apply Feature Scaling?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 25-Mar-2026 339 Views

Feature scaling is a crucial data preprocessing step applied to independent variables or features. It normalizes data within a particular range, ensuring all features contribute equally to machine learning algorithms. Why Feature Scaling is Important Most datasets contain features with vastly different magnitudes, units, and ranges. For example, age (20-80) versus income (20, 000-100, 000). Machine learning algorithms that use Euclidean distance treat these differences literally ? import numpy as np from sklearn.preprocessing import StandardScaler # Example: Age vs Income (unscaled) data = np.array([[25, 50000], [30, 75000], [35, 100000]]) print("Original data:") print("Age | Income") for ...

Read More

Maximum factors formed by two numbers in Python

Sunidhi Bansal
Sunidhi Bansal
Updated on 25-Mar-2026 2K+ Views

We are given an array of integers and need to find the maximum number of factors formed by multiplying any two distinct numbers from the array. This involves calculating all possible products of pairs and then counting factors for each product. Problem Understanding Example 1 For array [3, 2, 10] ? Input: [3, 2, 10] Products: 3×2=6, 3×10=30, 2×10=20 Factors: 6→{1, 2, 3, 6} (4 factors), 30→{1, 2, 3, 5, 6, 10, 15, 30} (8 factors), 20→{1, 2, 4, 5, 10, 20} (6 factors) Output: Maximum factors = 8 Example 2 For ...

Read More

Find bitonic point in given bitonic sequence in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 716 Views

A bitonic sequence is a sequence of numbers that first increases strictly, reaches a peak (the bitonic point), then decreases strictly. We need to find this peak element efficiently using binary search. The bitonic point is the maximum element where the left neighbor is smaller and the right neighbor is also smaller. Algorithm We use binary search to find the bitonic point in O(log n) time ? Compare the middle element with its neighbors If array[mid-1] < array[mid] > array[mid+1], we found the bitonic point If array[mid] < array[mid+1], the peak is in the right ...

Read More

Find array with k number of merge sort calls in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 190 Views

Sometimes we need to construct an array that requires exactly k recursive calls when sorted using merge sort. This problem involves understanding how merge sort's recursive structure works and manipulating an array to achieve the desired call count. Given two numbers a and b, we need to find an array containing values in range [1, a] that requires exactly b number of recursive merge sort calls. Understanding the Problem Merge sort makes recursive calls by dividing the array into halves. The total number of calls follows a pattern based on the array structure and element positions. ...

Read More
Showing 6571–6580 of 8,546 articles
« Prev 1 656 657 658 659 660 855 Next »
Advertisements