Server Side Programming Articles

Page 71 of 2109

How to Clean String Data in a Given Pandas DataFrame?

Mukul Latiyan
Mukul Latiyan
Updated on 27-Mar-2026 2K+ Views

String data in Pandas DataFrames often requires cleaning before analysis. This includes removing whitespace, handling special characters, standardizing case, and dealing with missing values. Pandas provides powerful string methods through the .str accessor to handle these tasks efficiently. Creating Sample Data Let's start with a DataFrame containing messy string data ? import pandas as pd # Create sample data with common string issues data = { 'Name': [' John Doe ', 'JANE SMITH', ' mary johnson ', ' Bob Wilson '], 'Email': ['john@EXAMPLE.com', 'jane@example.COM', 'mary@Example.com', ...

Read More

Reduce Data Dimensionality using PCA - Python

Jaisshree
Jaisshree
Updated on 27-Mar-2026 384 Views

Any dataset used in Machine Learning algorithms may have numerous dimensions. However, not all of them contribute to efficient output and simply cause the ML Model to perform poorly because of increased size and complexity. Thus, it becomes important to eliminate such features from the dataset using Principal Component Analysis (PCA). PCA helps in removing dimensions from the dataset that do not optimize results, thereby creating a smaller and simpler dataset with most of the original and useful information. PCA is based on feature extraction, which maps data from higher dimensional space to lower dimensional space while maximizing variance. ...

Read More

Recommendation System in Python

Jaisshree
Jaisshree
Updated on 27-Mar-2026 824 Views

Recommendation systems are tools in Python that suggest items or content to users based on their preferences and past behaviors. This technology utilizes algorithms to predict users' future preferences, thereby providing them with the most relevant content. The scope of this system is vast, with widespread use in various industries such as e-commerce, streaming services, and social media. Products, movies, music, books, and more can all be recommended through these systems. The provision of personalized recommendations not only helps foster customer engagement and loyalty but can also boost sales. Types of Recommendation Systems Content-Based Recommendation Systems ...

Read More

Classification of Text Documents using the Naive Bayes approach in Python

Jaisshree
Jaisshree
Updated on 27-Mar-2026 378 Views

Naive Bayes algorithm is a powerful tool for classifying text documents into different categories. For example, if a document contains words like 'humid', 'rainy', or 'cloudy', we can use the Bayes algorithm to determine if this document belongs to a 'sunny day' or 'rainy day' category. The algorithm works on the assumption that words in documents are independent of each other. While this assumption is rarely true in natural language, the algorithm still performs well enough in practice − hence the term 'naive' in its name. Algorithm Steps Step 1 − Input the documents, text strings ...

Read More

BLEU Score for Evaluating Neural Machine Translation using Python

Jaisshree
Jaisshree
Updated on 27-Mar-2026 773 Views

Using NMT or Neural Machine Translation in NLP, we can translate a text from a given language to a target language. To evaluate how well the translation is performed, we use the BLEU or Bilingual Evaluation Understudy score in Python. The BLEU Score works by comparing machine translated sentences to human translated sentences, both in n-grams. Also, with the increase in sentence length, the BLEU score decreases. In general, a BLEU score is in the range from 0 to 1 and a higher value indicates a better quality. However, achieving a perfect score is very rare. Note that the ...

Read More

Python – Merge Element of Sublists

Pranavnath
Pranavnath
Updated on 27-Mar-2026 679 Views

In Python programming, merging sublist elements from two different lists is a common operation when working with complex data structures. This technique is essential for tasks such as data manipulation, analysis, and combining information from multiple sources. When you have nested lists and need to combine corresponding sublists, Python offers several efficient approaches. Each method has its own advantages in terms of readability, performance, and flexibility. What is Sublist Merging? Merging elements of sublists refers to combining individual elements from different sublists into a single unified structure. This operation is commonly used when working with nested lists ...

Read More

Finding the Maximum and Minimum value from two Python Lists

Pranavnath
Pranavnath
Updated on 27-Mar-2026 5K+ Views

Python provides several built-in functions to find maximum and minimum values from two lists. Understanding these approaches helps you choose the right method based on your specific requirements. Built-in Functions Python offers two essential functions for finding extreme values: max() − Returns the highest value from an iterable or multiple arguments min() − Returns the lowest value from an iterable or multiple arguments Method 1: Using List Concatenation Combine both lists and find the overall maximum and minimum values ? # Initialize two lists with integer values list_a = [5, 9, ...

Read More

Python - Minimum Key Equal Pairs

Pranavnath
Pranavnath
Updated on 27-Mar-2026 188 Views

Finding minimum key equal pairs means finding the smallest value for each unique key in a collection of key-value pairs. Python offers several efficient approaches to solve this problem using dictionaries, itertools, and collections module. Understanding Key Concepts Dictionaries: Python dictionaries use curly braces {} and store key-value pairs. Access values using square brackets with the key inside. Lambda Functions: Anonymous functions defined in a single line, commonly used with higher-order functions like sorted() and min(). DefaultDict: A subclass of dict that automatically creates missing keys with default values, eliminating KeyError exceptions. Method 1: Using ...

Read More

Finding the Maximum Distance between Elements using Python

Pranavnath
Pranavnath
Updated on 27-Mar-2026 1K+ Views

Finding the maximum distance between duplicate elements in a Python list is a common problem in data analysis. The distance refers to the difference between the highest and lowest index positions where the same element appears. Problem Understanding Given a list with duplicate elements, we need to find the maximum distance between any two occurrences of the same element. For example, in the list [1, 3, 5, 1, 5, 7, 8], the element 5 appears at indices 2 and 4, giving a distance of 2. Using NumPy Module NumPy provides efficient array operations to find unique ...

Read More

Python – Mean of Consecutive Sublist

Pranavnath
Pranavnath
Updated on 27-Mar-2026 183 Views

When working with lists in Python, calculating the mean of consecutive sublists is a common task in data analysis. This involves dividing a list into fixed-size chunks and computing the average of each chunk. Python offers several approaches to accomplish this efficiently. What is Mean of Consecutive Sublists? Given a list and a sublist size, we divide the original list into consecutive sublists of that size and calculate the mean (average) of each sublist. For example, if we have [1, 2, 3, 4, 5, 6] and sublist size is 3, we get sublists [1, 2, 3] and [4, ...

Read More
Showing 701–710 of 21,090 articles
« Prev 1 69 70 71 72 73 2109 Next »
Advertisements