Finding Words Lengths in String using Python

Aayush Shukla
Updated on 27-Mar-2026 11:01:10

4K+ Views

Finding the lengths of individual words in a string is a common task in text processing and data analysis. Python provides several approaches to accomplish this, from simple loops to more advanced techniques using regular expressions and dictionaries. Methods Used Using a loop and the split() function Using the map() function with len and split() Using the re.split() method from the re module Using a Dictionary to store word lengths Using a Loop and the split() Function This is the most straightforward ... Read More

Change Value in Excel Using Python

Mukul Latiyan
Updated on 27-Mar-2026 11:00:47

5K+ Views

In this article, we will learn different approaches to change values in Excel files using Python. We'll explore two main libraries: openpyxl for modern Excel formats and xlwt/xlrd/xlutils for legacy formats. Using Openpyxl Openpyxl is a Python library designed for working with Excel spreadsheets. It supports modern Excel file formats including: XLSX (Microsoft Excel Open XML Spreadsheet) XLSM (Microsoft Excel Open XML Macro−Enabled Spreadsheet) XLTM (Microsoft Excel Open XML Macro−Enabled Template) XLTX (Microsoft Excel Open XML Template) Key Features Reading and Writing: Create, modify, and save Excel files Data Manipulation: Sort, filter, ... Read More

Cluster Sampling in Pandas

Mukul Latiyan
Updated on 27-Mar-2026 11:00:15

899 Views

In this article, we will learn how we can perform cluster sampling in Pandas. But before we deep dive into that, let's explore what sampling is in Pandas and how it helps us analyze data efficiently. Sampling in Pandas In Pandas, sampling refers to the process of selecting a subset of rows or columns from a DataFrame or Series object. Sampling can be useful in many data analysis tasks, such as data exploration, testing, and validation. Pandas provides several methods for sampling data, including: DataFrame.sample(): This method returns a random sample of rows from a ... Read More

Clear LRU Cache in Python

Mukul Latiyan
Updated on 27-Mar-2026 10:59:31

13K+ Views

In this article, we will learn how to clear an LRU cache implemented in Python. LRU Cache (Least Recently Used Cache) is a data structure that improves application performance by storing frequently-used data and removing the least recently used items when the cache becomes full. The LRU Cache is particularly useful in applications with high-cost data retrieval operations, such as disk I/O or network access. By caching frequently-used data in memory, applications can significantly reduce expensive operations and improve performance. Understanding LRU Cache in Python Python's functools module provides the @lru_cache decorator to implement LRU caching. This ... Read More

Check if a String is Present in a Pdf File in Python

Mukul Latiyan
Updated on 27-Mar-2026 10:58:45

874 Views

In today's digital world, PDF files have become an essential medium for storing and sharing information. Python provides several libraries that allow us to interact with PDF files and extract information from them. One common task is to search for a particular string within a PDF file. However, the simple text-based approach shown below has significant limitations. Opening a PDF file as plain text will not work properly because PDFs contain binary data, formatting, and metadata. For real PDF processing, you should use specialized libraries like PyPDF2 or pdfplumber. Basic Text Search Approach (Limited) This approach treats ... Read More

Change the View of Tensor in PyTorch

Mukul Latiyan
Updated on 27-Mar-2026 10:58:23

381 Views

PyTorch tensors support the view() method to reshape tensor dimensions without copying data. This is essential for deep learning operations where you need to transform tensor shapes for different layers. What is tensor.view()? The view() method returns a new tensor with the same data but different shape. It's memory-efficient because it creates a new view of the existing data rather than copying it. Syntax tensor.view(*shape) tensor.view(rows, columns) The total number of elements must remain constant. For a tensor with 12 elements, valid shapes include (12, ), (3, 4), (2, 6), etc. Basic ... Read More

How to remove axes spine from the plot in seaborn?

Niharika Aitam
Updated on 27-Mar-2026 10:57:55

996 Views

The axes spines, also known as the axis lines, are the lines that define the borders or boundaries of a plot's coordinate system. In a two-dimensional plot, there are typically four axes spines: top, bottom, left, and right. These spines create the framework for the plot and serve as reference lines for the data points. Each spine represents one of the four sides of the plot. The top spine runs horizontally across the top, the bottom spine runs horizontally across the bottom, the left spine runs vertically along the left side, and the right spine runs vertically along the ... Read More

CMY and CMYK Color Models using Python

Niharika Aitam
Updated on 27-Mar-2026 10:57:27

3K+ Views

The CMY and CMYK color models are subtractive color models used in printing and graphic design. In Python, we can work with these color models using libraries like matplotlib and PIL to create, manipulate, and visualize colors. CMY Color Model The CMY color model, also known as the subtractive color model, is a system used for mixing colors in printing, painting, and graphic design. CMY stands for Cyan, Magenta, and Yellow, which are the primary colors in this model. In the CMY color model, colors are created by subtracting different amounts of cyan, magenta, and yellow pigments ... Read More

How to change the figure style to Ticks in Seaborn?

Niharika Aitam
Updated on 27-Mar-2026 10:56:58

1K+ Views

In Seaborn, the ticks figure style is a minimalistic style that removes the background grid lines but retains the tick marks on the axes. This style focuses on presenting the data without any distracting elements and is useful when we want a clean and simple look for our plots. What the Ticks Style Does When we set the figure style to ticks in Seaborn using the sns.set_style() function, the following changes occur in our plots: Background Grid Lines − The background grid lines are removed, resulting in a blank canvas without any horizontal or vertical lines. ... Read More

What is the way to convert the figure style to Whitegrid in Seaborn?

Niharika Aitam
Updated on 27-Mar-2026 10:56:38

417 Views

Seaborn is a popular data visualization library in Python that provides a variety of styles to enhance the visual appearance of plots. One of the available styles is "whitegrid, " which offers a clean white background with subtle grid lines that make data easier to read and interpret. In this article, we'll explore how to convert the figure style to whitegrid in Seaborn and demonstrate its usage with practical examples. Setting Up the Environment First, ensure you have Seaborn installed in your Python environment. You can install it using pip ? pip install seaborn ... Read More

Advertisements