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 on Trending Technologies
Technical articles with clear explanations and examples
Adding a new column to existing DataFrame in Pandas in Python
In this tutorial, we are going to learn how to add a new column to an existing DataFrame in pandas. There are several methods to accomplish this task, each with its own advantages depending on your specific needs. Using Direct Assignment The simplest way to add a new column is by using direct assignment with a list. This method assigns the new column data to the DataFrame like a dictionary element − Example # importing pandas import pandas as pd # creating a DataFrame data = { 'Name': ['Hafeez', 'Aslan', ...
Read MoreAnagram checking in Python program using collections.Counter()
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. For example, thing and night are anagrams of each other. In this article, we are going to learn how to check an anagram in a Python program using collections.Counter() method. This method counts the number of occurrences of each element in a collection (like characters in a string), helping us to compare two words for identical character counts ? Understanding the Problem Input: str1= "listen", str2= "silent" Output: True ...
Read MoreAnalysing Mobile Data Speeds from TRAI with Pandas in Python
The Telecom Regulatory Authority of India (TRAI) publishes data regarding mobile internet speeds for various telecom operators across India. This data is useful for users and telecom companies to evaluate and compare the performance of different service providers. In this article, we are going to use pandas in Python to analyze the TRAI mobile data speed reports. Let's assume we have a CSV file named demo.csv with the following structure to use in the examples. Sample Data Structure ...
Read MoreApply function to every row in a Pandas DataFrame in Python
In this tutorial, we will learn how to apply functions to every row in a Pandas DataFrame using the apply() method. This is useful when you need to perform calculations across columns or transform data row-wise. The apply() Method The apply() method is used to apply a function along an axis of a DataFrame. When axis=1, it applies the function to each row. This is particularly useful for creating new columns based on calculations involving multiple existing columns. Using Custom Functions with Lambda You can apply custom functions to each row using lambda expressions ? ...
Read MoreApply uppercase to a column in Pandas dataframe in Python
In this tutorial, we are going to see how to make a column of names to uppercase in DataFrame. Let's see different ways to achieve our goal. Using str.upper() Method We can convert a column to uppercase using the str.upper() method. This is the most common and efficient approach for string operations in pandas. # importing the pandas package import pandas as pd # data for DataFrame data = { 'Name': ['Hafeez', 'Aslan', 'Kareem'], 'Age': [19, 21, 18], 'Profession': ['Developer', 'Engineer', 'Artist'] } ...
Read MoreArithmetic Operations on Images using OpenCV in Python
In this tutorial, we are going to learn about the arithmetic operations on Images using OpenCV. We can apply operations like addition, subtraction, Bitwise Operations, etc. Let's see how we can perform operations on images. We need the OpenCV module to perform operations on images. Install the OpenCV module using the following command in the terminal or command line. pip install opencv-python Image Addition We can add two images using the cv2.addWeighted() function. It takes five arguments: two images, the weights for each image, and a scalar value added to the final result. ...
Read Moreas_integer_ratio() in Python for reduced fraction of a given rational
In this tutorial, we are going to write a program that returns two numbers whose ratio is equal to the given float value. The as_integer_ratio() method helps to achieve our goal by converting a float into its exact fractional representation. Let's see some examples ? Input: 1.5 Output: 3 / 2 Input: 5.3 Output: 5967269506265907 / 1125899906842624 Syntax The as_integer_ratio() method is called on a float value and returns a tuple containing the numerator and denominator ? float_value.as_integer_ratio() Return Value Returns a tuple (numerator, denominator) where both are ...
Read MoreAudio processing using Pydub and Google Speech Recognition API in Python
Audio processing is essential for converting speech to text in applications like transcription services and voice assistants. This tutorial demonstrates how to use Pydub for audio manipulation and Google Speech Recognition API to extract text from audio files. Installing Required Libraries First, install the necessary packages using pip − pip install pydub speechrecognition audioread How It Works The process involves two main steps: Audio Chunking: Breaking large audio files into smaller segments for better processing Speech Recognition: Converting each audio chunk to text ...
Read MoreBarnsley Fern in Python
The Barnsley Fern is a fractal pattern created by mathematician Michael Barnsley that resembles the shape of a natural fern. It is generated using four mathematical transformations known as an Iterated Function System (IFS), where each transformation has different probabilities of being selected. Mathematical Foundation The Barnsley Fern uses four affine transformations, each with the general form ? f(x, y) = [a b] [c d] [x] [y] + [e] [f] The four transformations ...
Read MoreBasic Python Programming Challenges
In this tutorial, we will create a Python quiz program that generates random arithmetic questions. The program asks users to solve basic math operations and provides a final score based on correct answers. Challenge Overview We need to build a program that: Generates random arithmetic operations (+, -, *, /, //, %) Takes user input for the number of questions Evaluates user answers and provides feedback Displays the final score Complete Solution Here's the complete arithmetic quiz program ? # importing random and operator modules import random import operator # ...
Read More