Vani Nalliappan

Vani Nalliappan

122 Articles Published

Articles by Vani Nalliappan

Page 10 of 13

Write a program in Python to check if a series contains duplicate elements or not

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 224 Views

A Pandas Series is a one-dimensional data structure that can contain duplicate values. To check if a series contains duplicates, we can compare the series length with the number of unique elements. Sample Series Data Let's start with a series that has no duplicate elements ? import pandas as pd import numpy as np # Series with no duplicates data = pd.Series([1, 2, 3, 4, 5]) print("Original Series:") print(data) Original Series: 0 1 1 2 2 3 3 4 4 ...

Read More

Write a program in Python to filter only integer elements in a given series

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 590 Views

When working with Pandas Series that contain mixed data types, you often need to filter only the integer elements. Python provides several approaches to accomplish this task using type checking, regular expressions, or built-in Pandas methods. Sample Data Let's start by creating a series with mixed data types ? import pandas as pd data_list = [1, 2, "python", "pandas", 3, 4, 5] series = pd.Series(data_list) print("Original Series:") print(series) Original Series: 0 1 1 2 2 ...

Read More

Write a program in Python to replace all odd index position in a given series by random uppercase vowels

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 310 Views

In this tutorial, we'll learn how to replace values at odd index positions in a Pandas Series with random uppercase vowels. This is useful for data masking or creating test datasets. Problem Statement Given a Series with numeric values, we need to replace all values at odd index positions (1, 3, 5, etc.) with random uppercase vowels (A, E, I, O, U). Input 0 1 1 2 2 3 3 4 4 5 dtype: int64 Expected Output ...

Read More

Write a program in Python to filter valid dates in a given series

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 260 Views

Filtering valid dates from a Pandas Series involves identifying date strings that follow a specific format. We'll explore two approaches: using regular expressions with loops and using Pandas filtering methods. Sample Data Let's start with a Series containing date strings in various formats ? import pandas as pd dates = ['2010-03-12', '2011-3-1', '2020-10-10', '11-2-2'] data = pd.Series(dates) print("Original Series:") print(data) Original Series: 0 2010-03-12 1 2011-3-1 2 2020-10-10 3 11-2-2 dtype: object ...

Read More

Write a program in Python to generate five random even index lowercase alphabets in a series

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 174 Views

In this article, we'll explore how to generate five random even-indexed lowercase alphabets and create a Pandas Series from them. Even-indexed characters are those at positions 0, 2, 4, 6, etc. in the alphabet. Using String Slicing (Recommended) The most efficient approach uses string slicing with step 2 to extract even-indexed characters − import pandas as pd import string import random chars = string.ascii_lowercase print("Lowercase alphabets:", chars) # Extract even-indexed characters using slicing even_chars = list(chars[::2]) print("Even-indexed characters:", even_chars) # Generate 5 random samples data = random.sample(even_chars, 5) print("Random even-indexed characters:", data) ...

Read More

Python program to filter perfect squares in a given series

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 659 Views

A perfect square is a number that can be expressed as the product of an integer with itself. In this tutorial, we'll learn how to filter perfect squares from a Pandas Series using different approaches. Given a series with numbers, we want to identify and filter only the perfect squares ? Input and Expected Output Input − 0 14 1 16 2 30 3 49 4 80 Output − 1 16 3 ...

Read More

How to use Python Pandas to find the total number of count for more than one special characters present in each word in a given series?

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 693 Views

When working with text data in Pandas, you might need to count words containing multiple special characters. This tutorial shows how to find the total count of words that have more than one special character in a given Series. Input Data Let's start with a sample series containing words with special characters ? import pandas as pd data = pd.Series(["fruits!!", "*cakes*", "$nuts", "#drinks"]) print(data) 0 fruits!! 1 *cakes* 2 $nuts 3 #drinks dtype: object ...

Read More

How to set the range of Y-axis in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 27-Aug-2023 30K+ Views

Plotly supports to the range on both X and Y axis. Let us understand how to set the range of Y-axis in Plotly. plotly.graph_objects is used to generate figures. It contains a lot of methods to customize charts and render a chart in HTML format. Create a numpy module and generate random ranges for both X and Y axis. Create Figure() method to plot X and Y axis with mode as lines Create update_layout() method and set the Y-axis range. Follow the steps given to set the range of Y-axis in Plotly. Step 1 − Import plotly Import ...

Read More

How to plot multiple lines on the same Y-axis in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Aug-2023 35K+ Views

Plotly is an open-source plotting library in Python that can generate several different types interactive web-based visualizations that can be displayed in Jupyter notebooks, saved to standalone HTML files, or served as a part of web applications using Dash. Plotly can also be used in static document publishing and desktop editors such as PyCharm and Spyder. In this tutorial, we will show how you can use Plotly to plot multiple lines on the same Y-axis on a chart. Here we will use plotly.express to generate figures. It contains a lot of methods to customize chart and render a chart into ...

Read More

How to display a variable as tooltip in ggplotly using R language?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Oct-2022 2K+ Views

R is a programming language for statistical computing and graphics. ggplotly() is a function used to convert static plots to web-based plots. ggplotly() returns a Plotly object. In this tutorial, we will see how to display a variable as tooltip in ggplotly using R language. Here, we will use the aes() function that is used for aesthetic mapping between visual cue and a variable. It contains the following arguments: position (X and Y axes), color, fill, shape, line type, and size. To set the tooltip text, we will use the ggplotly(tooltip = " ") method. Follow the steps ...

Read More
Showing 91–100 of 122 articles
« Prev 1 8 9 10 11 12 13 Next »
Advertisements