Core9X
Log inSign up

MBOSE Class XII Informatics Practices · Chapter 3

Data Handling Using Pandas – II

Opening soon

Learn to summarise, sort, group and reshape data with Pandas, deal with missing values, and move data between Pandas and MySQL.

14 lessons · 56 practice questions · unit "Data Handling using Pandas and Data Visualisation" carries 25 marks

See classes open nowLog inMBOSE Class XII opens to new students soon.

What this chapter covers

  • Descriptive statistics — max, min, sum, count, mean, median, mode, quartiles, variance, standard deviation, describe()
  • Data aggregation
  • Sorting
  • GROUP BY
  • Altering the index
  • Reshaping — pivot() and pivot_table()
  • Handling missing values — isnull(), dropna(), fillna()
  • Import and export between Pandas and MySQL

Key terms

Descriptive statistics

Measures summarising data (mean, median, …)

Quartile

Value dividing sorted data into quarters

Aggregation

Summarising data with functions

GROUP BY

Splitting data into groups for aggregation

Pivot

Reshaping rows into columns

pivot_table

Pivot that aggregates duplicate entries

NaN

Missing value

SQLAlchemy

Toolkit that creates a database engine

Important questions with answers

10 of the 56 questions on this chapter, solved.

  1. Question 1 · Multiple choice · 1 mark

    The middle value of sorted data is the

    • (a) median
    • (b) mean
    • (c) mode
    • (d) range

    Answer: (a) median

    median().

  2. Question 2 · Multiple choice · 1 mark

    count() counts

    • (a) all values including NaN
    • (b) the columns
    • (c) the rows
    • (d) the non-NaN values

    Answer: (d) the non-NaN values

    Missing values are skipped.

  3. Question 3 · Multiple choice · 1 mark

    The default aggfunc of pivot_table() is

    • (a) mean
    • (b) sum
    • (c) count
    • (d) max

    Answer: (a) mean

    It can be changed.

  4. Question 4 · Multiple choice · 1 mark

    Rows containing NaN are removed with

    • (a) dropna()
    • (b) fillna()
    • (c) isnull()
    • (d) drop_nan()

    Answer: (a) dropna()

    fillna() replaces them.

  5. Question 5 · Assertion and reason · 1 mark

    Assertion (A): pivot_table() works with duplicate entries.

    Reason (R): It aggregates them using aggfunc.

    • (a) Both A and R are true, and R is the correct explanation of A.
    • (b) Both A and R are true, but R is not the correct explanation of A.
    • (c) A is true, but R is false.
    • (d) A is false, but R is true.

    Answer: (a) Both A and R are true, and R is the correct explanation of A.

    Mean by default.

  6. Question 6 · Short answer · 2 marks

    Distinguish median and mode.

    Answer

    Median is the middle value of sorted data; mode is the most frequent value.

  7. Question 7 · Short answer · 2 marks

    What is SQLAlchemy?

    Answer

    A Python toolkit that creates a database engine for Pandas to read and write SQL tables.

  8. Question 8 · Short answer · 3 marks

    Write code to save df to a MySQL table marks.

    Answer

    df.to_sql('marks', engine, if_exists='replace', index=False).

  9. Question 9 · Long answer · 5 marks

    Explain the descriptive statistics functions of Pandas.

    Answer

    Section 1.1; Exercise Q6–Q7.

  10. Question 10 · Long answer · 5 marks

    Explain pivot() and pivot_table() with examples.

    Answer

    Section 1.3; Section 8.2 (HSSLC 2020, Q9(b) (second choice)).

Study the whole chapter

14 step-by-step lessons, all 56 practice questions with hints, flashcards and mock tests for MBOSE Class XII Informatics Practices.

See classes open nowLog inMBOSE Class XII opens to new students soon.