Tarun Singh

Tarun Singh

90 Articles Published

Articles by Tarun Singh

90 articles

How to parse XML and count instances of a particular node attribute in Python?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 1K+ Views

Parsing XML and counting instances of a particular node attribute in Python can be achieved through various methods. XML is a widely used format for storing and exchanging structured data. Python provides several libraries for parsing XML, including ElementTree, lxml, and xml.etree.ElementTree. In this article, we will explore different approaches to parse XML and count instances of a particular node attribute using available XML parsing libraries with practical examples. Using ElementTree ElementTree is part of Python's standard library and provides a straightforward method for parsing and manipulating XML documents. It offers a lightweight API for parsing XML ...

Read More

How to Order PySpark DataFrame by Multiple Columns?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 2K+ Views

When working with large datasets, one common PySpark operation is to order a DataFrame by multiple columns. You can prioritize the sorting based on various criteria when you sort data based on multiple columns. PySpark provides several methods to accomplish this task, each with different features and performance characteristics. In this article, we will learn how to order PySpark DataFrame by multiple columns using three different approaches: orderBy(), sort(), and sortWithinPartitions(). Method 1: Using orderBy() The orderBy() method sorts the DataFrame in ascending or descending order based on one or more columns. It returns a new DataFrame ...

Read More

How to move your Game Character Around in Pygame?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 3K+ Views

Pygame is a powerful library that allows developers to create engaging 2D games using Python. One fundamental aspect of game development is implementing smooth and responsive character movement. In this article, we will learn how to move your game character around in Pygame using different techniques including basic movement, grid-based movement, and smooth rotation effects. Setting up the Basic Game Structure First, let's create the foundation for character movement by setting up Pygame and the game window ? import pygame # Initialize Pygame pygame.init() # Set up the game window screen_width, screen_height = ...

Read More

How to open two files together in Python?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 4K+ Views

When working with Python projects, you often need to open and process multiple files simultaneously. Python provides several elegant approaches to handle two or more files together, ensuring proper resource management and efficient file operations. Method 1: Using the 'with' Statement The 'with' statement is the most Pythonic way to open multiple files. It automatically handles file closing and ensures proper resource cleanup ? Syntax with open('file1.txt', 'r') as file1, open('file2.txt', 'r') as file2: # Code to process both files Example # Create sample files for demonstration ...

Read More

How to move list of folders with subfolders using Python?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 829 Views

Moving folders with their subfolders is a common task in file management and data organization. Python provides several built-in modules like shutil and os that make this process straightforward and reliable. In this article, we will explore different approaches to move a list of folders with subfolders using Python, examining their syntax, use cases, and practical examples. Why Python for Moving Folders? Python's os and shutil modules provide powerful file system operations ? os module − Low-level operating system interface for file operations shutil module − High-level file operations with built-in error handling Cross-platform − ...

Read More

How to merge multiple folders into one folder using Python?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 3K+ Views

Data in today's time is generated in large volumes, and organizing that data can be a challenging task. One of the most common issues people face is merging multiple folders into one. It can be quite frustrating to search for a specific file when you have multiple folders to navigate through. Fortunately, Python provides a simple solution to this problem. In this article, we will learn how to merge multiple folders into one folder using Python. To merge multiple folders into one, we will be using the os and shutil modules that provide a portable way of using operating ...

Read More

How to merge multiple excel files into a single file with Python?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 12K+ Views

Excel is one of the most popular tools for data analysis and management. Often, we need to merge multiple Excel files into a single file for analysis or sharing with others. Manually merging these files can be time−consuming and prone to errors, especially when dealing with large datasets. Luckily, Python provides an efficient and flexible way to merge multiple Excel files into a single file. In this article, we will learn how to merge multiple Excel files using Python. We will be using the Pandas library, which is a powerful and easy−to−use data analysis library for Python to merge ...

Read More

How to merge many TSV files by common key using Python Pandas?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 838 Views

If you work with data, you've probably had to deal with the challenge of merging multiple files into one cohesive dataset. This task can be particularly difficult if you're working with tab-separated values (TSV) files. Fortunately, the Python Pandas library provides a straightforward solution for merging TSV files by a common key. In this article, we'll learn how to merge multiple TSV files using Python Pandas. We'll explore different merging techniques including merge() for joining by common keys and concat() for combining files with identical structures. What are TSV Files? TSV files are a type of delimited ...

Read More

How to merge a transparent PNG image with another image using PIL?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 2K+ Views

In image processing, merging a transparent PNG image with another image is a common operation. This creates composite images where the transparent PNG overlays seamlessly on top of a background image. In this article, we will learn how to merge a transparent PNG image with another image using PIL (Python Imaging Library). PIL is a powerful library for working with images in Python, supporting various formats including JPEG, PNG, BMP, GIF, and TIFF. Basic Steps for Image Merging To merge a transparent PNG image with another image using PIL, we need to follow these steps − ...

Read More

How to open an image from the URL in PIL?

Tarun Singh
Tarun Singh
Updated on 27-Mar-2026 6K+ Views

PIL (Python Imaging Library) is a widely used Python library that enables developers to work with image files. It offers a broad range of functionalities for manipulating and handling image files, such as opening and resizing them, converting between different formats, and more. One frequently encountered task when working with images involves opening an image file from a URL. This is especially useful when working with images that are stored on a remote server, such as those obtained from an online database or a website. In this article, we will learn how to open an image from the ...

Read More
Showing 1–10 of 90 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements