Prasad Naik has Published 74 Articles

How to calculate the frequency of each item in a Pandas series?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:55:14

348 Views

In this program, we will calculate the frequency of each element in a Pandas series. The function value_counts() in the pandas library helps us to find the frequency of elements.AlgorithmStep 1: Define a Pandas series. Step 2: Print the frequency of each item using the value_counts() function.Example Codeimport pandas as ... Read More

Finding the multiples of a number in a given list using NumPy

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:54:33

1K+ Views

In this program, we will find the index position at which a multiple of a given number exists. We will use both the Numpy and the Pandas library for this task.AlgorithmStep 1: Define a Pandas series. Step 2: Input a number n from the user. Step 3: Find the multiples ... Read More

Comparing two Pandas series and printing the the difference

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:49:44

2K+ Views

In this program, we will compare two Pandas series and will print the differences in the series. By difference, we mean that the index positions at which the elements did not match.AlgorithmStep 1: Define two Pandas series, s1 and s2. Step 2: Compare the series using compare() function in the ... Read More

Print the standard deviation of Pandas series

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:48:04

285 Views

In this program, we will find the standard deviation of a Pandas series. Standard deviation is a statistic that measures the dispersion of a dataset relative to its mean and is calculated as the square root of the variance.AlgorithmStep 1: Define a Pandas series Step 2: Calculate the standard deviation ... Read More

Print the mean of a Pandas series

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:47:48

906 Views

mean() function in the Pandas library can be used to find the mean of a series.AlgorithmStep 1: Define a Pandas series. Step 2: Use the mean() function to calculate the mean. Step 3: Print the mean.Example Codeimport pandas as pd series = pd.Series([10, 20, 30, 40, 50]) print("Pandas Series: ... Read More

How to append elements to a Pandas series?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:43:12

14K+ Views

In this program, we will append elements to a Pandas series. We will use the append() function for this task. Please note that we can only append a series or list/tuple of series to the existing series.AlgorithmStep1: Define a Pandas series, s1. Step 2: Define another series, s2. Step 3: ... Read More

How to sort a Pandas Series?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:42:52

223 Views

In this problem we have to sort a Pandas series. We will define an unsorted pandas series and will sort it using the sort_values() function in the Pandas library.AlgorithmStep 1: Define Pandas series. Step 2: Sort the series using sort_values() function. Step 3: Print the sorted series.Example Codeimport pandas as ... Read More

Python program to reverse a Numpy array?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:42:12

486 Views

This is a simple program wherein we have to reverse a numpy array. We will use numpy.flip() function for the same.AlgorithmStep 1: Import numpy. Step 2: Define a numpy array using numpy.array(). Step 3: Reverse the array using numpy.flip() function. Step 4: Print the array.Example Codeimport numpy as np ... Read More

How to print array elements within a given range using Numpy?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:41:54

573 Views

In this program, we have to print elements of a numpy array in a given range. The different numpy functions used are numpy.where() and numpy.logical_and().AlgorithmStep 1: Define a numpy array. Step 2: Use np.where() and np.logical_and() to find the numbers within the given range. Step 3: Print the result.Example Codeimport ... Read More

How to find set difference between two Numpy arrays?

Prasad Naik

Prasad Naik

Updated on 16-Mar-2021 10:41:10

10K+ Views

In this program, we will find the set difference of two numpy arrays. We will use the setdiff1d() function in the numpy library. This function takes two parameters: array1 and array2 and returns the unique values in array1 that are not in array2.AlgorithmStep 1: Import numpy. Step 2: Define two ... Read More

Advertisements