Kiran P

Kiran P

107 Articles Published

Articles by Kiran P

Page 4 of 11

How to find and filter Duplicate rows in Pandas ?

Kiran P
Kiran P
Updated on 25-Mar-2026 7K+ Views

Sometimes during data analysis, we need to examine duplicate rows to understand patterns in our data rather than dropping them immediately. Pandas provides several methods to find, filter, and handle duplicate rows effectively. The duplicated() Method The duplicated() method identifies duplicate rows in a DataFrame. Let's work with an HR dataset to demonstrate this functionality ? import pandas as pd import numpy as np # Import HR Dataset with certain columns df = pd.read_csv("https://raw.githubusercontent.com/sasankac/TestDataSet/master/HRDataset.csv", usecols=["Employee_Name", "PerformanceScore", "Position", "CitizenDesc"]) ...

Read More

How to select a Subset Of Data Using lexicographical slicingin Python Pandas?

Kiran P
Kiran P
Updated on 25-Mar-2026 401 Views

Pandas provides powerful indexing capabilities to select subsets of data. Lexicographical slicing allows you to select data based on alphabetical ordering of string indexes, similar to how words are arranged in a dictionary. Loading and Exploring the Dataset Let's start by importing a movies dataset and examining its structure − import pandas as pd import numpy as np movies = pd.read_csv("https://raw.githubusercontent.com/sasankac/TestDataSet/master/movies_data.csv", index_col="title", ...

Read More

How to select subset of data with Index Labels in Python Pandas?

Kiran P
Kiran P
Updated on 25-Mar-2026 2K+ Views

Pandas provides powerful selection capabilities to extract subsets of data using either index positions or index labels. This article demonstrates how to select data using index labels with the .loc accessor. The .loc attribute works similar to Python dictionaries, selecting data by index labels rather than positions. This is different from .iloc which selects by integer position like Python lists. Setting Up the Dataset Let's start by importing a movies dataset with the title as the index ? import pandas as pd movies = pd.read_csv("https://raw.githubusercontent.com/sasankac/TestDataSet/master/movies_data.csv", ...

Read More

How to Find The Largest Or Smallest Items in Python?

Kiran P
Kiran P
Updated on 25-Mar-2026 494 Views

Finding the largest or smallest items in a collection is a common task in Python. This article explores different methods to find single or multiple largest/smallest values efficiently. Method 1: Using min() and max() for Single Items For finding a single smallest or largest item (N=1), min() and max() are the most efficient functions ? import random # Create a random list of integers random_list = random.sample(range(1, 10), 9) print("List:", random_list) # Find the smallest number smallest = min(random_list) print("Smallest:", smallest) # Find the largest number largest = max(random_list) print("Largest:", largest) ...

Read More

How to Identify Most Frequently Occurring Items in a Sequence with Python?

Kiran P
Kiran P
Updated on 25-Mar-2026 371 Views

When analyzing sequences of data, identifying the most frequently occurring items is a common task. Python's Counter from the collections module provides an elegant solution for counting and finding the most frequent elements in any sequence. What is a Counter? The Counter is a subclass of dictionary that stores elements as keys and their counts as values. Unlike regular dictionaries that raise a KeyError for missing keys, Counter returns zero for non-existent items. from collections import Counter # Regular dictionary raises KeyError regular_dict = {} try: print(regular_dict['missing_key']) except KeyError as e: ...

Read More

How to save HTML Tables data to CSV in Python

Kiran P
Kiran P
Updated on 16-Mar-2026 2K+ Views

Extracting data from HTML tables and saving it to CSV format is a common task in data science and web scraping. When dealing with multiple tables on a webpage, manual copy-paste becomes impractical, making automated extraction essential. This tutorial demonstrates how to use Python libraries like csv, urllib, and BeautifulSoup to scrape HTML table data and convert it to CSV format efficiently. Required Libraries Before starting, ensure you have the necessary libraries installed − pip install beautifulsoup4 The csv and urllib= len(tables): ...

Read More

Write a program in Go language to find the element with the maximum value in an array

Kiran P
Kiran P
Updated on 11-Mar-2026 706 Views

ExamplesA1 = [2, 4, 6, 7, 8, 10, 3, 6, 0, 1]; Maximum number is 10A2 = [12, 14, 16, 17, 18, 110, 13, 16, 10, 11]; Maximum number is 110Approach to solve this problemStep 1: Consider the number at the 0th index as the maximum number, max_num = A[0]Step 2: Compare max_num with every number in the given array, while iterating.Step 3: If a number is greater than max_num, then assign that number to max_num;Step 4: At the end of iteration, return max_num;Programpackage main import "fmt" func findMaxElement(arr []int) int {    max_num := arr[0]    for i:=0; i max_num ...

Read More

Write a Golang program to find the element with the minimum value in an array

Kiran P
Kiran P
Updated on 11-Mar-2026 967 Views

ExamplesA1 = [2, 4, 6, 7, 8, 10, 3, 6, 0, 1]; Minimum number is 0;A2 = [12, 14, 16, 17, 18, 110, 13, 16, 10, 11]; Minimum number is 10;Approach to solve this problemStep 1: Consider the number at the 0th index as the minimum number, min_num = A[0].Step 2: Compare min_num with every number in the given array, while iterating.Step 3: If a number is smaller than min_num, then assign that number to min_num.Step 4: At the end of iteration, return min_num;Programpackage main import "fmt" func findMinElement(arr []int) int {    min_num := arr[0]    for i:=0; i

Read More

Write a Golang program to check whether a given number is prime number or not

Kiran P
Kiran P
Updated on 11-Mar-2026 5K+ Views

Definition: A number is that is greater than 2 and divisible only by itself and 1.Examples: Prime numbers are 2, 3, 5, 7, 11, 13, 113, 119, ..., etc.Approach to solve this problemStep 1: Find square root of the given number, sq_root = √numStep 2: If the given number is divisible by a number that belongs to [2, sq_root], then print “Non Prime Number”Step 3: If not divisible by any number, then print “Prime Number”Programpackage main import (    "fmt"    "math" ) func checkPrimeNumber(num int) {    if num < 2 {       fmt.Println("Number must be greater than 2.")       return    }    sq_root := int(math.Sqrt(float64(num)))    for i:=2; i

Read More

Write a Golang program to search an element in an array

Kiran P
Kiran P
Updated on 11-Mar-2026 478 Views

Definition: A number is that is greater than 2 and divisible only by itself and 1.Examples: Prime numbers are 2, 3, 5, 7, 11, 13, 113, 119, ..., etc.Approach to solve this problemStep 1: Find square root of the given number, sq_root = √numStep 2: If the given number is divisible by a number that belongs to [2, sq_root], then print “Non Prime Number”Step 3: If not divisible by any number, then print “Prime Number”Programpackage main import (    "fmt"    "math" ) func checkPrimeNumber(num int) {    if num < 2 {       fmt.Println("Number must be greater than 2.")       return    }    sq_root := int(math.Sqrt(float64(num)))    for i:=2; i

Read More
Showing 31–40 of 107 articles
« Prev 1 2 3 4 5 6 11 Next »
Advertisements