Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Niharika Aitam
Page 2 of 14
Python - Column wise sum of nested list
A nested list in Python is a list that contains other lists as elements, creating a multidimensional structure. When working with nested lists representing tabular data, calculating column-wise sums is a common requirement. In a nested list structure where each inner list represents a row, the elements at the same index across different inner lists form columns. Let's explore different methods to calculate column-wise sums. Understanding Nested List Structure Consider a nested list where each inner list represents a row of data: nested_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] print("Nested list:", ...
Read MorePython - Column Product in List of lists
The column product refers to the result of multiplying all the values within a specific column of a dataset. In a tabular representation of data, such as a list of lists or a spreadsheet, each column typically represents a variable or a feature, and the values within that column represent individual observations or measurements. When calculating the column product, the values within a specific column are multiplied together to obtain a single value that represents the combined effect of the variables or observations within that column. This can be useful in various data analysis and modeling scenarios, such as ...
Read MorePython - Column summation uneven in sized lists
Column summation refers to the process of calculating the sum of values within each column of a dataset or matrix. In Python, this becomes challenging when dealing with uneven-sized lists where columns have different lengths. What is Column Summation Column summation involves adding up values within each column to obtain a single sum for each variable. Consider this dataset representing heights in centimeters across three measurements ? Measurement 1 Measurement 2 Measurement 3 Person 0 170 175 180 Person 1 165 168 172 Person 2 180 182 178 ...
Read MorePython - Column Mean in tuple list
The column mean in a tuple list refers to the average value of elements within each column of the tuple data. A tuple list is a collection of tuples, where each tuple represents a record or observation, and the elements within each tuple correspond to different columns or variables. Column means are particularly useful when dealing with numerical data and performing statistical analysis or making data-driven decisions. For example, consider the following tuple list: data = [(1, 2, 3), (4, 5, 6), ...
Read MoreProgram to Print K using Alphabets
Python provides various ways to create letter patterns using text characters. The letter K can be printed using different approaches and alphabets from the English language. Method 1: Using 'K' Character with Mathematical Logic This approach uses mathematical conditions to determine where to place the 'K' character ? string = "" j = 7 i = 0 for Row in range(0, 10): for Col in range(0, 10): if (Col == 1 or ...
Read MoreProgram to print window pattern
A window pattern is a visual representation that resembles a window frame using characters like asterisks (*) or plus signs (+). Python makes it easy to create such patterns using loops and string operations. Simple Rectangular Window Let's start with a basic rectangular window without any divisions ? def print_window(n): # Print the top row print("+" * (2 * n + 1)) # Print the middle rows for i in range(n - 1): ...
Read MoreDivide one Hermite series by another in Python using NumPy
The Hermite series is a mathematical technique used to represent infinite series of Hermite polynomials. Hermite polynomials are orthogonal polynomials that solve the Hermite differential equation. NumPy provides functions to work with Hermite series, including division operations. What is a Hermite Series? A Hermite series is represented by the equation: f(x) = Σn=0^∞ cn Hn(x) Where: Hn(x) is the nth Hermite polynomial cn is the nth coefficient in the expansion Creating Hermite Series First, let's create Hermite series using NumPy's polynomial.hermite.poly2herm() function − import numpy as np from numpy.polynomial ...
Read MoreDivide a DataFrame in a ratio
Pandas DataFrames often need to be divided into smaller parts based on specific ratios for tasks like train-test splits in machine learning. Python provides several methods to split DataFrames proportionally using different approaches. There are three main ways to divide DataFrame data based on ratio: Using np.random.rand() Using pandas.DataFrame.sample() Using numpy.split() Using numpy.random.rand() This method creates random values for each row and filters based on a threshold. For a 60-40 split, we use 0.6 as the threshold ? Syntax import numpy as np ratio = np.random.rand(len(dataframe)) part1 = dataframe[ratio < threshold] ...
Read MoreDigital Band Pass Butterworth Filter in Python
A Band Pass Filter is a filter that passes frequencies within a specific range and rejects frequencies outside this range. The Butterworth band pass filter is designed to have the flattest possible frequency response in the pass band, making it ideal for applications requiring minimal ripple. Filter Specifications The following specifications define a typical digital band pass Butterworth filter: Sampling rate: 40 kHz Pass band edge frequencies: 1400 Hz to 2100 Hz Stop band edge frequencies: 1050 Hz to 2450 Hz Pass band ripple: 0.4 dB Minimum stop band attenuation: 50 dB Implementation Steps ...
Read MoreDifferentiate Hermite series and multiply each differentiation by scalar using NumPy in Python
The Hermite_e series (probabilist's Hermite polynomial) is a mathematical function used in quantum mechanics and probability theory. NumPy provides the hermite.hermder() function to differentiate Hermite series and multiply each differentiation by a scalar value. Hermite_e Series Formula The Hermite_e polynomial is defined as: H_n(x) = (−1)^n e^(x²/2) d^n/dx^n(e^(−x²/2)) Where: H_n(x) is the nth Hermite polynomial of degree n x is the independent variable d^n/dx^n denotes the nth derivative with respect to x Syntax The polynomial.hermite.hermder() function syntax is: numpy.polynomial.hermite.hermder(c, m=1, scl=1, axis=0) Parameters: c − Array ...
Read More