- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a program in Python to find the missing element in a given series and store the full elements in the same series
Solution
To solve this, we will follow the steps given below −
Define a Series.
Create a for loop and access the data from start to end elements. Set if condition to check the data is present or not.
If the value is not in the range then append it to the list. Finally, sort and print the values.
for i in range(data[0],data[length-1]): if(i not in data): l1.append(i) else: l1.append(i)
Example
Let us see the following implementation to get a better understanding.
import pandas as pd import numpy as np l = [1,2,3,6,7] l1 = [] data = pd.Series(l) length = len(data) for i in range(data[0],data[length-1]): if(i not in data): l1.append(i) else: l1.append(i) l1.sort() data = pd.Series(l1) print(data)
Output
0 1 1 2 2 3 3 4 4 5 5 6
- Related Articles
- Write a Python program to shuffle all the elements in a given series
- Write a program in Python to round all the elements in a given series
- Write a program in Python to find the most repeated element in a series
- Write a program in Python to print the power of all the elements in a given series
- Write a program in Python to sort all the elements in a given series in descending order
- Write a program in Python to filter only integer elements in a given series
- Write a program in Python to find the index for NaN value in a given series
- Write a program in Python to slice substrings from each element in a given series
- Write a program in Python to find the maximum length of a string in a given Series
- Write a program in Python to print the most frequently repeated element in a series
- Write a program in Python to print the elements in a series between a specific range
- Write a Python program to find the maximum value from first four rows in a given series
- Write a program in Python to print the day of the year in a given date series
- Write a program in Python to resample a given time series data and find the maximum month-end frequency
- Write a program in Python to filter valid dates in a given series

Advertisements