Important Questions For Python Panda 2 Class 12 Informatics Practices (IP)
Note:- Please Click on Question to get the Answer !!
  Q1. Name the functions you can use to iterate over data frames.
Q2. What is the basic difference between iterrows() and
      iteritems()?
Q3. In Binary addition, if a column in a data frame contains a NaN and
      the corresponding column in other Data Frame is a numeric value, then what
      would be returned as a result? Why?
Q4. Given two data frame df3 and df4 as shown below:
Both
      these data-frames store integer values but when they are added as df3+
      df4, the values in the resultant object automatically change to floating
      point (as shown on above right) contrary to the fact the two integers when
      added will result into integer only. Can you specify the reason ?
Q5. Given two Data frames One and Two as shown here:
What will
      be the result of the following?
(a) One.radd(Two)
(b) One +
      Two
(c) One.rsub(Two)
Q6. Write equivalent function for the following operations on two
      Data-frames A and B
(i) A+B
(ii) B+A
(iii) A-B
(iv)
      B-A
(v) B*A
(vi) B/A
(vii) A/B
Q7. Given a data-frame namely wdf as shown below:
(i) Write
      command to compute sum of every column of the data frame.
(ii) Write
      command to compute mean of column Rainfall.
(iii) Write command to
      compute sum of every row of the data frame.
(iv) Write command to
      compute average of all the columns for last 10 rows only.
(v) Write
      command to compute average maxTemp, Rainfall for first 10 rows.
Q8. What is pivoting? Which functions of Pandas support pivoting?
Q9. What is a quartile? How is it related to quantile? How do you
      generate it in Pandas?
Q10. What is the difference between pivot() and pivot_table()
      functions?
Q11. A data frame fdf stores data about passengers, flights and years.
      First few rows of the data frame are shown below.
Using above
      data-frame, write commands for the following:
(a) Compute total
      passengers per year.
(b) Compute average passengers per month.
Q12. What is descriptive statistics ? Name the functions commonly used
      for calculating this.
Q13. What is missing data? Why is it considered a problem?
Q14. Write command to print cumulative sum of columns Rainfall and
      Evaporation in the data-frame wdf given below.
Q15. Is there any one function that performs descriptive statistics on a
      data frame?
Q16. What functions does Pandas provide to handle missing data?
Q17. Consider the same data frames One and Two. Write a statements that
      the missing value of One is filled or combined from the corresponding
      value of data-frame Two. Also show the result after combining the
      values.
Q18. Consider the data-frames One and Two given in. What will be the
      output of following statements:-
(a) pd.concat( [One, Two])
(b)
      pd.concat( [One, Two], axis = 1)
(c) pd.merge (One, Two, on =
      'name')
Q19. Write a program to iterate over a data frame containing names and
      marks, which then calculates grades as per marks (as per guidelines below)
      and adds them to the grade column.
Marks >= 90 grade A+;
Marks
      70-90 grade A;
Marks 68-70 grade B;
Marks 50-60 grade C;
Marks
      40-50 grade D;
Marks < 40 grade F
Q20. Given a Data Frame df:-
Write a program to print only the
      Name, Age and Position for all rows.
Q21. Consider the crop statistics Data Frame prodf. Write a program to
      print the minimum crop production for each crop.
Q22. Consider the crop statistics Data Frame prodf. Write a program to
      print the average crop production for each crop.
Q23. Consider the Data Frame df  :
Write a program to
      summaries how much budget is allocated to different Positions, for each
      City ?
Q24. Consider the original Data Frame mk. Write a program to calculate
      average marks for each section.
Q25. Given a data frame Sales that store sales records of a company
      of past few years. But the data frame contains some missing data.
Write
      a script that does the following:-
(i) Lists the presence of missing
      data in whole data frame.
(ii) Fills the missing values with 999.
(iii)
      Print the data frame after filling missing value.
Q26. Consider Data Frame mk as shown below:
Write a program to
      fill missing values section wise as given below and name the new Data
      Frame as nmk :
For section 'A' fill 20,
For section 'B' fill
      10,
For section 'C' fill 20,
For section 'D' fill 0
Q27. Consider the Data Frame mk, write a program to calculate
      average marks for each section after filling up of missing values.
Q28. Consider Data Frames pdf and pdf2 as shown below:
Write a
      program to fill the missing values in pdf with corresponding values.
Q29. Consider the crop statistics Data Frame prodf. Write a program to
      calculate mean absolute deviation for all the crops.
Q30. Consider the crop statistics Data Frame prodf. Write a program to
      calculate mean absolute deviation for all the states.
Q31. Consider the following data-frame, and answer the questions given
      below:
import pandas as pd
df = pd.DataFrame({
      
"Quarter1": [2000, 4000, 5000, 4400, 10000],
"Quarter2": [5800,
      2500, 5400, 3000, 2900],
"Quarter3": [20000,16000,7000,3600,8200],
"Quarter4":
      [1400, 3700, 1700, 2000, 6000]})
(i) Write the code to find
      mean value from above data-frame df over the index and column axis.
(ii)
      Use sum() function to find the sum of all the values over the index
      axis.
(iii) Find the median of the data-frame df.
Q32. Given a data frame df1 as shown below:
(i) Write command
      to compute sum of every column of the data frame.
(ii) Write command
      to compute mean of column Rainfall.
(iii) Write command to compute
      Median of the Max Temp Column.
Q33. Consider the two data frames namely emp and dept given below:
Write
      a program to join these two data frames on their indexes, but keep in mind
      that both data-frames have a common column name which, if not handled,
      leads to error.
Q34. Consider the data frames emp and dept. Write a program to create a
      data frame that stores the merged data frames emp and dept, joined on the
      basis of dept_id and contain all the rows of both the data-frames.
Q35. Create a Data Frame QtrSales where each row contains the item
      category, item name, and expenditure. Locate the 3 largest values of
      Expenditure in this data frame.
Q36. Write the output for the Python statement based on the dataframe cricket provided below.
     Name    Age    Score
0    Sachin    26    87
1    Dhoni    25    67
2    Virat    25    89
3    Rohit    24    55
4    Shikhar    31    47
df ['Age'].quantile ([0.25, 0.5, 0.75])
Q37. Write a Python statement using the above dataframe Student to get a new dataframe with name taken as index and implementing pivoting.
Q38. Explain the transform dataframe function.
Q39. Write the code fragment to sort the given dataframe (say df and consisting of students' details) in descending order of AdmNo.
Q40. Consider the following Python code and write the output for statement S1.
import pandas as pd
K = pd.series([2, 4, 6, 8, 10, 12, 14])
K.quantile([0.50,0.75])
Q41. Assume that the following data is stored in a dataframe named df1. Write the commands to:
(i) find total sales per state
(ii) find total sales per employee
(iii) find total sales both employee-wise and state-wise
(iv) find mean, median and min sale state-wise
(v) find maximum sale by individual
Q42. What is pivoting? Name any two functions of Pandas which support pivoting.
Q43. Give the output for the following code:
import pandas as pd
data = [{'a': 1, 'b': 2}, {'a1': 5, 'b1': 10, 'c1': 20}]
df1 = pd.DataFrame(data, index = ['first', 'second'], columns = ['a', 'b'])
df2 = pd.DataFrame(data, index = ['first', 'second'], columns = ['a', 'b1'])
print (df1)
print (df2)
Q44. Given the dataset for weather forecast:
Perform all the aggregate and statistical functions you have learnt in the chapter on the basis of the given dataset.
Note: Create dataframe for the given dataset before applying the functions.
Q45. If query is a string storing an SQL statement, write statements so that the data is fetched based on query from SQL database Mydata.db.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )