Found 10783 Articles for Python

Python - Plotting Area charts in excel sheet using XlsxWriter module

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:32:24

201 Views

An area chart represents the change in a one or more quantities over time. It is made by plotting a series of data points over time, connecting those data points with line segments, and then filling in the area between the line and the x-axis with color or shading.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_area.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method ... Read More

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

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:24:37

121 Views

Charts are composed of at least one series of one or more data points. Series themselves are comprised of references to cell ranges. For plotting the charts on an excel sheet, firstly, create chart object of specific chart type( i.e Column chart etc.). After creating chart objects, insert data in it and lastly, add that chart object in the sheet object.Example# import xlsxwriter module import xlsxwriter #Workbook()takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_pattern.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() ... Read More

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

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:21:30

135 Views

XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs.Example# import xlsxwriter module import xlsxwriter # Workbook() takes one, non-optional, argument which is the filename #that we want to create. workbook = xlsxwriter.Workbook('chart_gradient1.xlsx') # The workbook object is then used to add new worksheet via the #add_worksheet() method. worksheet = workbook.add_worksheet() # Create a new Format object to formats cells in worksheets using #add_format() method . # here we create bold format object . bold = workbook.add_format({'bold': 1}) # Add the worksheet data that the charts will refer ... Read More

Python - Number of values greater than K in list

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:14:09

640 Views

One of the basic problems for many complex problems is finding numbers greater than certain number in list in python, is commonly encountered.Example Live Demo# find number of elements > k using for loop # initializing list test_list = [1, 7, 5, 6, 3, 8] # initializing k k = 4 # printing list print ("The list : " + str(test_list)) # using for loop to get numbers > k count = 0 for i in test_list :    if i > k :       count = count + 1 # printing the intersection print ("The numbers greater than ... Read More

Python - Implementation of Polynomial Regression

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:12:29

361 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)Example# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset datas = pd.read_csv('data.csv') datas # divide the dataset into two components X = datas.iloc[:, 1:2].values y = datas.iloc[:, 2].values # Fitting Linear Regression to the dataset from sklearn.linear_model import LinearRegression lin = LinearRegression() lin.fit(X, y) ... Read More

Python - Image Classification using keras

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:08:19

290 Views

Image classification is a method to classify the images into their respective category classes using some method like −Training a small network from scratchFine tuning the top layers of the model using VGG16Example#First, include following libraries: # 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 as K #Here, the train_data_dir is the train dataset directory. validation_data_dir is the #directory for validation data. nb_train_samples is the total number train #samples. nb_validation_samples is the total number of validation samples. img_width, img_height = 224, 224 train_data_dir = ... Read More

Python - How and where to apply Feature Scaling?

Nizamuddin Siddiqui
Updated on 06-Aug-2020 12:00:35

170 Views

It is a step of Data pre-processing which is applied to independent variables or features of data. It basically helps to normalise the data within a particular range.Why scaling?Most of the times, your dataset will contain features highly varying in magnitudes, units and range. But since, most of the machine learning algorithms use Euclidian distance between two data points in their computations, this is a problem.If left alone, these algorithms only take in the magnitude of features neglecting the units. The results would vary greatly between different units, 5kg and 5000gms.The features with high magnitudes will weigh in a lot ... Read More

Python - Getting started with SymPy module

Nizamuddin Siddiqui
Updated on 06-Aug-2020 11:54:41

554 Views

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python. SymPy only depends on mpmath, a pure Python library for arbitrary floating point arithmetic, making it easy to use.#Installing sympy modulepip install sympySymPy defines following numerical types: Rational and Integer. The Rational class represents a rational number as a pair of two Integers, numerator and denominator, so Rational(1, 2) represents 1/2, Rational(5, 2) 5/2 and so on. The Integer class represents Integer number.SymPy ... Read More

Maximum factors formed by two numbers in Python

Sunidhi Bansal
Updated on 03-Aug-2020 10:30:26

963 Views

We are given with an array of integer type elements and the task is to find the maximum factors formed by multiplying two numbers i.e. firstly we will multiply the numbers present in an array like calculating cross product secondly, we will calculate the factors of those numbers and check for the maximum factors amongst all.Inputint arr[] = {3, 2, 10}OutputMaximum factors formed by two numbers are: 8ExplanationCalculate the inner cross product i.e. 3 * 2 = 6, 3 * 10 = 30, 2 * 10 = 20Now calculate the factors for 6 -> 1, 2, 3, 6 ; 30 ... Read More

Find bitonic point in given bitonic sequence in Python

Arnab Chakraborty
Updated on 28-Aug-2020 12:14:27

397 Views

Suppose we have a bitonic sequence, we have to find the Bitonic Point in it. As we know a Bitonic Sequence is a sequence of numbers which is first strictly increasing then after a certain point it is strictly decreasing. This point is bitonic point. For only increasing or only decreasing sequences, bitonic points are not available.So, if the input is like [7, 8, 9, 12, 10, 6, 3, 2], then the output will be 12To solve this, we will follow these steps −define a function binary_search(array, l, r)if l array[m + 1], then −return mif array[m] < array[m ... Read More

Advertisements