Python Articles

Page 694 of 855

Apply function to every row in a Pandas DataFrame in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 1K+ Views

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 More

Apply uppercase to a column in Pandas dataframe in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

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 More

Arithmetic Operations on Images using OpenCV in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 1K+ Views

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 More

as_integer_ratio() in Python for reduced fraction of a given rational

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 489 Views

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 More

Audio processing using Pydub and Google Speech Recognition API in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 962 Views

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 More

Barnsley Fern in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 524 Views

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 More

Basic Python Programming Challenges

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 615 Views

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

Beginner Tips for Learning Python

Vikram Chiluka
Vikram Chiluka
Updated on 25-Mar-2026 443 Views

Python is a beginner-friendly programming language widely used for web development, automation, data analysis, and software creation. Its simple syntax and versatility make it an ideal starting point for aspiring programmers. This guide provides practical tips to help beginners learn Python effectively. Master the Fundamentals First Building a solid foundation is crucial for understanding advanced Python concepts later ? Setting Up Python Install Python from the official website (python.org) and use IDLE or a code editor like VS Code to write your first programs. Essential Basics to Learn # Basic syntax - print ...

Read More

Data analysis and Visualization with Python program

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 461 Views

Data analysis and visualization are essential skills in Python programming. This tutorial covers the fundamentals using two powerful libraries: pandas for data manipulation and matplotlib for creating visualizations. Installation Install the required packages using pip − pip install pandas matplotlib Introduction to Pandas Pandas is an open-source library that provides high-performance data analysis tools. It offers data structures like DataFrame and Series for handling structured data efficiently. Creating DataFrames A DataFrame is a two-dimensional data structure with labeled rows and columns. Here's how to create one from scratch ? ...

Read More

Amazing hacks of Python

sudhir sharma
sudhir sharma
Updated on 25-Mar-2026 295 Views

Python is one of the programming languages known for its simple syntax and readability. Whether working on development, data analysis, or automation, Python provides the tools to get tasks done with less effort. But beyond the basics, Python has some hacks that make code not only shorter but also more efficient. These are not bugs or workarounds, but smart ways of using Python built-in features and functions to solve tasks in a faster manner. In this article, we are going to learn about amazing hacks of Python that can improve your coding efficiency. Performing a Swap Without ...

Read More
Showing 6931–6940 of 8,549 articles
« Prev 1 692 693 694 695 696 855 Next »
Advertisements