Server Side Programming Articles

Page 78 of 2109

Python - Remove Sublists that are Present in Another Sublist

Aayush Shukla
Aayush Shukla
Updated on 27-Mar-2026 293 Views

When working with nested lists in Python, you may need to remove sublists that are contained within other sublists. This is useful for removing redundant data and cleaning up your data structures. Understanding the Problem Consider a list where some sublists are completely contained within other sublists ? duplicate_list = [['Aayush', 'Shyam', 'John'], ['Shyam', 'John'], ['Henry', 'Joe'], ['David', 'Stefen', 'Damon'], ['David', 'Stefen']] print("Original list:") print(duplicate_list) Original list: [['Aayush', 'Shyam', 'John'], ['Shyam', 'John'], ['Henry', 'Joe'], ['David', 'Stefen', 'Damon'], ['David', 'Stefen']] Here, ['Shyam', 'John'] is contained in ['Aayush', 'Shyam', 'John'], and ['David', 'Stefen'] ...

Read More

How to Unzip a list of Python Tuples

Aayush Shukla
Aayush Shukla
Updated on 27-Mar-2026 694 Views

Unzipping a list of tuples means separating the tuple elements into distinct lists or collections. Python provides several methods to accomplish this task, with zip() being the most common and efficient approach. Using zip() with Unpacking Operator The most Pythonic way to unzip tuples uses zip() with the unpacking operator * − places = [('Ahmedabad', 'Gujarat'), ('Hyderabad', 'Telangana'), ('Silchar', 'Assam'), ('Agartala', 'Tripura'), ('Namchi', 'Sikkim')] cities, states = zip(*places) print("Cities:", cities) print("States:", states) Cities: ('Ahmedabad', 'Hyderabad', 'Silchar', 'Agartala', 'Namchi') States: ('Gujarat', 'Telangana', 'Assam', 'Tripura', 'Sikkim') Using List Comprehension Extract specific ...

Read More

How to Remove Square Brackets from a List using Python

Aayush Shukla
Aayush Shukla
Updated on 27-Mar-2026 15K+ Views

Python lists are displayed with square brackets by default when printed. Sometimes you need to display list contents without these brackets for better formatting or presentation purposes. This article covers six different methods to remove square brackets from Python lists. Method 1: Using str() and replace() The simplest approach is to convert the list to a string and replace the bracket characters with empty strings − # List containing elements names = ["Jack", "Harry", "Sam", "Daniel", "John"] # Convert to string and remove brackets result = str(names).replace('[', '').replace(']', '') print(result) 'Jack', 'Harry', ...

Read More

How to conduct Grid search using python?

Jay Singh
Jay Singh
Updated on 27-Mar-2026 322 Views

Grid search is a systematic approach to hyperparameter tuning in machine learning. It evaluates all possible combinations of specified hyperparameters to find the optimal configuration. Python's Scikit-learn provides powerful tools like GridSearchCV and RandomizedSearchCV to automate this process with cross-validation. Understanding Grid Search Grid search works by defining a parameter grid containing different values for each hyperparameter. The algorithm trains and evaluates the model for every combination, selecting the configuration that yields the best cross-validation score. Complete Grid Search Example Creating the Dataset First, let's create a synthetic dataset using Scikit-learn − from ...

Read More

Disease Prediction Using Machine Learning with examples

Suneel Raja
Suneel Raja
Updated on 27-Mar-2026 2K+ Views

Disease prediction is a crucial application of machine learning that can help improve healthcare by enabling early diagnosis and intervention. Machine learning algorithms can analyze patient data to identify patterns and predict the likelihood of a disease or condition. In this article, we will explore how disease prediction using machine learning works with practical examples. Disease Prediction Workflow Disease prediction using machine learning involves the following steps ? Data collection ? The first step is to collect patient data, including medical history, symptoms, and diagnostic test results. This data is then compiled into a dataset. Data ...

Read More

Display the Pandas DataFrame in table style

Suneel Raja
Suneel Raja
Updated on 27-Mar-2026 7K+ Views

Pandas DataFrames can be displayed in various table formats for better visualization and analysis. This article explores different methods to present DataFrame data in a clean, readable table style. Using the print() Function The simplest way to display a Pandas DataFrame in table style is using the print() function. Pandas automatically formats the data into a tabular layout ? import pandas as pd # Create a sample DataFrame data = { 'name': ['John', 'Jane', 'Bob', 'Alice'], 'age': [25, 30, 35, 40], 'gender': ['M', ...

Read More

Display the Pandas DataFrame in Heatmap style

Suneel Raja
Suneel Raja
Updated on 27-Mar-2026 2K+ Views

Pandas is a powerful data analysis library that offers a wide range of functions to work with structured data. One of the most popular ways to represent data is through a heatmap, which allows you to visualize data in a tabular format with colors representing the values. In this article, we will explore how to display a Pandas DataFrame in a heatmap style using the Seaborn library. A heatmap is a graphical representation of data where individual values are represented by colors. It's particularly useful for identifying patterns, correlations, and outliers in datasets at a glance. Installing Required ...

Read More

Display scientific notation as float in Python

Suneel Raja
Suneel Raja
Updated on 27-Mar-2026 15K+ Views

Scientific notation is a standard way of representing very large or very small numbers in the scientific and mathematical fields. However, in some cases, it may be more convenient to display these numbers in traditional decimal format. Python provides several methods to convert and display scientific notation as regular floats. Using the float() Function The simplest way to convert scientific notation to a float is using the float() function. It takes a string representation of scientific notation and returns a floating-point number ? # Converting scientific notation string to float number_in_scientific = "1.234e+6" result = float(number_in_scientific) ...

Read More

Display NumPy array in Fortran order

Suneel Raja
Suneel Raja
Updated on 27-Mar-2026 849 Views

In this article, we will explore how to display a NumPy array in Fortran order. By default, NumPy arrays are stored in row-major order (C-order), but sometimes it's necessary to work with column-major order (Fortran-order), especially in scientific computing applications. C-Order (Row-Major) 1 2 3 4 5 6 Fortran-Order (Column-Major) 1 ...

Read More

Display Images on Terminal using Python

Suneel Raja
Suneel Raja
Updated on 27-Mar-2026 2K+ Views

Displaying images on a terminal window can be a useful and fun feature to add to your Python programs. It can be used to create ASCII art, display diagrams or charts, or simply show images in a terminal-based interface. In this article, we'll explore how to display images on a terminal using Python. First, let's understand the basic concept of displaying images on a terminal. A terminal window is essentially a text-based interface that displays characters on the screen. Therefore, to display an image, we need to convert it into characters that can be displayed on a terminal. ...

Read More
Showing 771–780 of 21,090 articles
« Prev 1 76 77 78 79 80 2109 Next »
Advertisements