Found 27104 Articles for Server Side Programming

How to Delete the True Values in a Python List?

Pranay Arora
Updated on 29-Aug-2023 12:59:15

193 Views

In Python, lists are perhaps of the most regularly used datum structures that permit us to store different elements. Now and then, we might experience circumstances where we really want to remove explicit elements from a list. In this article, we will discuss five distinct methods to remove the True values from a Python list. We will examine the algorithm, give code examples, show the result, and close with a correlation of the methods. Introduction Consider a situation where we have a list containing a combination of boolean type and different information types, and we need to remove all events ... Read More

How to Convert Dictionary values to Absolute Magnitude using Python?

Pranay Arora
Updated on 29-Aug-2023 12:56:53

104 Views

Dictionaries are data structures that can contain key and values of any data type. The values can be of integer type as well. In this article we are going to see How to Convert Dictionary values to Absolute Magnitude using Python which simply means if a value is in negative it will be converted to it’s absolute or positive value while positive values will remain as it is. I/O Example Input = {'a':1 , 'b' : -1} Output = {'a':1 , 'b' : 1} To do this conversion, there are lot of techniques however 1 function that ... Read More

How to Convert dictionary to K sized dictionaries using Python?

Pranay Arora
Updated on 29-Aug-2023 12:54:11

61 Views

Dictionaries are key-value data structures in python where in the keys are unique and values can be repeated or not. The keys and values can be of any data type. In this article we are going to see How to Convert dictionary to K sized dictionaries using Python which simply means we will divide a dictionary into k-smaller dictionaries where k is any positive number i.e. k>0. Example Let the input dictionary be d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'x': 8, 'y': 9} The corresponding output should be {'a': 1, ... Read More

How to take integer input in Python?

Tushar Sharma
Updated on 28-Aug-2023 20:49:34

505 Views

The acquisition of integer input holds immense significance in various programming tasks, and the Python programming language offers a plethora of techniques to achieve this goal. This article embarks on an insightful journey to explore diverse methodologies for acquiring integer input in Python, focusing on the following strategies: Unveiling the Potential of the `input()` Function and `int()` Type Conversion Harnessing the Versatility of the `map()` Function Unearthing Integer Input from File Sources Attaining Integer Input via Command Line Arguments Method 1: ... Read More

How to swap columns of a given NumPy array?

Tushar Sharma
Updated on 28-Aug-2023 20:48:11

1K+ Views

When it comes to manipulating NumPy arrays, there might be instances where you want to interchange the positions of two columns. In this article, we delve into four distinct techniques to exchange columns in a given NumPy array: utilizing advanced indexing, employing NumPy indexing, harnessing the np.swapaxes function, and leveraging direct assignment. We will comprehend these methods through illustrative examples. Method 1: Exploiting Advanced Indexing Unleashing the potential of advanced indexing, you open the capability to reshape the course of action of measurements inside a NumPy cluster, much obliged to a choosy curated program of column indices. ... Read More

How to suppress the use of scientific notations for small numbers using NumPy?

Tushar Sharma
Updated on 28-Aug-2023 20:45:14

114 Views

When working with NumPy arrays, you may encounter small numbers represented in scientific notation. Although this compact representation is advantageous, deciphering or comparing values can be arduous. This guide delves into four distinct techniques to abate scientific notation usage for diminutive numbers in NumPy arrays: employing numpy.vectorize alongside string formatting, utilizing numpy.ndarray.round, leveraging string formatting, and harnessing numpy.set_printoptions. Examples will elucidate these methodologies, discussing pros and cons, and providing an all-encompassing comprehension of each approach. Method 1: Using numpy.vectorize with string formatting numpy.vectorize function, when combined with string formatting, can suppress scientific notation in NumPy arrays. This approach ... Read More

How to Subtract Two Columns in Pandas DataFrame?

Tushar Sharma
Updated on 28-Aug-2023 20:41:06

3K+ Views

While working with Pandas DataFrames, situations may arise where arithmetic operations between attributes are necessary. One such operation is deducting two attributes. In this guide, we will delve into three distinct techniques to deduct two attributes in a Pandas DataFrame: employing the `sub` method, utilizing the `apply` method combined with a lambda function, and leveraging the `subtract` function. Examples will aid in understanding these approaches. Method 1: Employing the `sub` method The `sub` method is an intrinsic Pandas function that facilitates direct deduction of one attribute from another. This technique is straightforward and effective for performing deductions between ... Read More

How to store XML data into a MySQL database using Python?

Tushar Sharma
Updated on 28-Aug-2023 20:43:01

714 Views

XML (eXtensible Markup Language) stands tall as a widely embraced format for storing and exchanging structured information. In the realm of efficient data storage and retrieval, MySQL has earned its reputation as a go-to relational database management system (RDBMS). Python, blessed with its versatile libraries, presents an exquisite union for seamlessly handling XML and MySQL. Embark on a journey with us as we dive into the art of storing XML data in a MySQL database using Python, unraveling each step with intricacy and flair. Step 1: Importing the Essential Libraries Let us kickstart our endeavor by importing the ... Read More

How to Stack Multiple Pandas DataFrames?

Tushar Sharma
Updated on 28-Aug-2023 20:34:13

175 Views

The vast universe of Python includes a shining constellation named Pandas. Recognized globally for its might in data management and manipulation, it empowers data analysts with tools that act as an extension of their thoughts, transforming ideas into reality. The crux of this discussion lies in a particular feature of Pandas, the fusion of DataFrames along an axis. When the challenge is to blend information from diverse origins or conglomerate data for a comprehensive analysis, Pandas offers a basket of functions like concat(), append(), and merge(). The onus is on us to pick the tool that aligns with our ... Read More

How to validate ISIN using Regular Expressions?

Shubham Vora
Updated on 31-Aug-2023 10:05:54

441 Views

In this problem, we will use the regular expression to validate the ISIN number in C++. The ISIN stands for the International Securities Identification Number. It is a unique code to identify stocks, financial bonds, etc. The length of the ISIN number can be 12 or 14, which provides international recognization of the particular stuff. Let’s understand the format of the ISIN number. Country code − It starts with two characters of the country code. Identifier − It contains 9 alphanumeric characters after the country code. Checksum − It contains the single digit which is used to detect errors ... Read More

Advertisements