Vani Nalliappan has Published 130 Articles

Write a Python program to generate random ten rows, two columns of vowels. If both the rows are matched with same vowels, then print the index and count of matched columns

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:38:34

39 Views

Assume, you have a dataframe,  col1 col2 0 o    e 1 e    e 2 i    u 3 e    o 4 i    i 5 u    o 6 e    a 7 u    o 8 a    u 9 e    aThe result for matched ... Read More

Write a program in Python to modify the diagonal of a given DataFrame by 1

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:36:03

284 Views

Assume, you have a dataframe0 1 20 10 20 30 1 40 50 60 2 70 80 90The result for replaced 1 by diagonal of a dataframe is −0 1 2 0 1 20 30 1 40 1 60 2 70 80 1SolutionTo solve this, we will follow the steps ... Read More

Write a program in Python to find the lowest value in a given DataFrame and store the lowest value in a new row and column

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:31:05

265 Views

Assume you have a dataframe, one two three 0 12 13 5 1 10 6 4 2 16 18 20 3 11 15 58The result for storing the minimum value in new row and column is −Add new column to store min value  one   two  three min_value 0 12 ... Read More

Write a program in Python to read sample data from an SQL Database

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:24:08

438 Views

Assume you have a sqlite3 database with student records and the result for reading all the data is,   Id Name 0 1 stud1 1 2 stud2 2 3 stud3 3 4 stud4 4 5 stud5SolutionTo solve this, we will follow the steps given below −Define a new connection. It ... Read More

Write a Pyton program to perform Boolean logical AND, OR, Ex-OR operations for a given series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:22:02

73 Views

Assume you have a series and the result for Boolean operations, And operation is: 0    True 1    True 2    False dtype: bool Or operation is: 0    True 1    True 2    True dtype: bool Xor operation is: 0    False 1    False ... Read More

Write a program in Python to transpose the index and columns in a given DataFrame

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:19:46

201 Views

Input −Assume you have a DataFrame, and the result for transpose of index and columns are, Transposed DataFrame is   0 1 0 1 4 1 2 5 2 3 6Solution 1Define a DataFrameSet nested list comprehension to iterate each element in the two-dimensional list data and store it in ... Read More

Write a program in Python to calculate the default float quantile value for all the element in a Series

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:11:38

66 Views

Input −Assume you have a series and default float quantilevalue is 3.0SolutionTo solve this, we will follow the steps given below −Define a SeriesAssign quantile default value .5 to the series and calculate the result. It is defined below, data.quantile(.5) ExampleLet us see the complete implementation to get a better ... Read More

Write a program in Python to count the records based on the designation in a given DataFrame

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:10:56

84 Views

Input −Assume, we have a DataFrame and group the records based on the designation is −Designation architect    1 programmer   2 scientist    2SolutionTo solve this, we will follow the below approaches.Define a DataFrameApply groupby method for Designation column and calculate the count as defined below, df.groupby(['Designation']).count()ExampleLet us see ... Read More

Write a program in Python to store the city and state names that start with ‘k’ in a given DataFrame into a new CSV file

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:07:57

500 Views

Input −Assume, we have DataFrame with City and State columns and find the city, state name startswith ‘k’ and store into another CSV file as shown below −City, State Kochi, KeralaSolutionTo solve this, we will follow the steps given below.Define a DataFrameCheck the city starts with ‘k’ as defined below, ... Read More

Write a Python code to select any one random row from a given DataFrame

Vani Nalliappan

Vani Nalliappan

Updated on 24-Feb-2021 09:05:45

337 Views

Input −Assume, sample DataFrame is,  Id Name 0 1 Adam 1 2 Michael 2 3 David 3 4 Jack 4 5 PeterOutputput −Random row is   Id    5 Name PeterSolutionTo solve this, we will follow the below approaches.Define a DataFrameCalculate the number of rows using df.shape[0] and assign to ... Read More

Advertisements