Vani Nalliappan has Published 130 Articles

Write a Python code to concatenate two Pandas series into a single series without repeating the index

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:47:22

324 Views

Input − Assume, you have a series and the result to concat the values without repeating the index is, 0    1 1    2 2    3 3    4 4    5 5    6SolutionTo solve this, we will follow these two steps −Define two SeriesConcat two series ... Read More

Write a Python code to create a series with your range values, generate a new row as sum of all the values and then convert the series into json file

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:45:38

367 Views

SolutionTo solve this, we will follow the steps given below −Define a series with a range of 1 to 10Find the sum of all the valuesConvert the series into JSON file formatLet us see the following implementation to get a better understanding.Exampleimport pandas as pd data = pd.Series(range(1, 11)) data['sum'] ... Read More

Write a program in Python to find the missing element in a given series and store the full elements in the same series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:44:26

210 Views

SolutionTo 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, ... Read More

Write a program in Python to find the index for NaN value in a given series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:42:32

673 Views

Input −Assume, you have a series, 0    1.0 1    2.0 2    3.0 3    NaN 4    4.0 5    NaNOutput − And, the result for NaN index is, index is 3 index is 5SolutionTo solve this, we will follow the steps given below −Define a Series.Create for ... Read More

Write a program in Python to generate any random five prime numbers between 100 to 150 in a Series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:41:08

772 Views

SolutionTo solve this, we will follow the steps given below −Define an empty listCreate a for loop and set range from 100 to 150Set another for loop to access the values from 2 to range of values and find the factors, if nothing is found then add to the list. ... Read More

Write a program in Python to filter the elements in a series which contains a string start and endswith ‘a’

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:37:41

48 Views

Input − Assume, you have a Series, 0    apple 1    oranges 2    alpha 3    aroma 4    betaOutput − And, the result for elements start and endswith ‘a’.2    alpha 3    aromaSolution 1Define a Series.Create regular expression to check start and endswith ‘a’r'^[a]$|^([a]).*\1$'Create an empty ... Read More

Write a program in Python to print the power of all the elements in a given series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:34:19

145 Views

Input − Assume, you have a series, 0    1 1    2 2    3 3    4Output − And, the result for the power of all elements in a series is, 0    1 1    4 2    27 3    256Solution 1Define a Series.Create transform method ... Read More

Write a program in Python to remove the elements in a series, if it contains exactly two spaces

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:31:30

149 Views

Input −Assume, you have a series, 0    This is pandas 1    python script 2    pandas seriesOutput −And, the result after removing an element contains exactly two spaces, 1    python script 2    pandas seriesSolution 1Define a Series.Create lambda filter method to apply a regular expression to ... Read More

Write a program in Python to sort all the elements in a given series in descending order

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:28:09

116 Views

Input − Assume, you have a Series, 0 abdef 1 ijkl 2 Abdef 3 oUijlOutput − And the result for all the elements in descending order, 3 oUijl 1 ijkl 0 abdef 2 AbdefSolutionTo solve this, we will follow the steps given below −Define a SeriesApply sort_values method with the ... Read More

Write a program in Python to verify kth index element is either alphabet or number in a given series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 06:26:46

91 Views

Input − Assume, you have a Series, a    abc b    123 c    xyz d    ijkSolutionTo solve this, we will follow the steps given below −Define a SeriesGet the index from userSet the if condition to check the value is digit or not. It is defined below, ... Read More

Advertisements