Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 9 MCQs Handling data with pandas

ECAP776 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Introduction to pandas Easy

    What is pandas mainly used for in Python?

  2. Question 2 of 60 Introduction to pandas Easy

    Which statement commonly imports pandas using its standard alias?

  3. Question 3 of 60 Series Easy

    What is a pandas Series?

  4. Question 4 of 60 Series Easy

    Which expression creates a pandas Series from a Python list?

  5. Question 5 of 60 Series Easy

    What does the index of a pandas Series contain?

  6. Question 6 of 60 DataFrame Easy

    What is a pandas DataFrame?

  7. Question 7 of 60 DataFrame Easy

    In a DataFrame, what do columns usually represent?

  8. Question 8 of 60 DataFrame Easy

    Which expression creates a DataFrame from a dictionary named data?

  9. Question 9 of 60 DataFrame Easy

    What does the shape attribute of a DataFrame return?

  10. Question 10 of 60 DataFrame Easy

    By default, what does df.head() display?

  11. Question 11 of 60 Sorting Easy

    Which DataFrame method sorts rows according to the values in a column?

  12. Question 12 of 60 Sorting Easy

    Which argument sorts DataFrame values in descending order?

  13. Question 13 of 60 Sorting Easy

    Which method sorts a DataFrame according to its index labels?

  14. Question 14 of 60 Working with CSV files Easy

    Which pandas function reads data from a CSV file?

  15. Question 15 of 60 Working with CSV files Easy

    Which DataFrame method writes data to a CSV file?

  16. Question 16 of 60 Working with CSV files Easy

    What is the purpose of index=False in df.to_csv("data.csv", index=False)?

  17. Question 17 of 60 Operations using DataFrame Easy

    If df is a DataFrame, what does df["Age"] usually return?

  18. Question 18 of 60 Operations using DataFrame Easy

    Which statement creates a new column named Total by adding columns A and B?

  19. Question 19 of 60 Operations using DataFrame Easy

    Which DataFrame method removes rows containing missing values by default?

  20. Question 20 of 60 Operations using DataFrame Easy

    What does df.describe() commonly provide for numerical columns?

  21. Question 21 of 60 Introduction to pandas Medium

    Which statement correctly imports pandas using its conventional alias and creates a labeled one-dimensional object?

  22. Question 22 of 60 Series Medium

    Given s1 = pd.Series([10, 20], index=['a', 'b']) and s2 = pd.Series([1, 2], index=['b', 'c']), what is the result of s1 + s2?

  23. Question 23 of 60 Series Medium

    For s = pd.Series([8, 12, 16], index=['x', 'y', 'z']), which expression returns the first two values by position?

  24. Question 24 of 60 DataFrame Medium

    What columns and number of rows are produced by pd.DataFrame({'name': ['Ana', 'Bo'], 'score': [80, 90]})?

  25. Question 25 of 60 DataFrame Medium

    A DataFrame df contains columns name, age, and city. Which expression returns a DataFrame containing only name and city?

  26. Question 26 of 60 Operations using DataFrame Medium

    Which expression selects rows where score is at least 70 and attempts is less than 3?

  27. Question 27 of 60 Operations using DataFrame Medium

    A DataFrame has numeric columns price and quantity. Which statement creates a total column containing their row-wise products?

  28. Question 28 of 60 Sorting Medium

    Which command sorts df by department in ascending order and then by salary in descending order?

  29. Question 29 of 60 Sorting Medium

    After filtering, a DataFrame has row labels [7, 2, 5]. Which expression sorts the rows by these labels without changing column order?

  30. Question 30 of 60 Working with CSV files Medium

    A file students.csv contains five columns. Which command reads only the name and grade columns?

  31. Question 31 of 60 Working with CSV files Medium

    The first column of sales.csv is named order_id and should become the DataFrame index. Which command does this while reading the file?

  32. Question 32 of 60 Working with CSV files Medium

    A CSV column named date contains values such as 2026-09-10. Which command asks pandas to convert that column to date-time values during import?

  33. Question 33 of 60 Operations using DataFrame Medium

    For a DataFrame containing only numeric values, what does df.mean(axis=1) calculate?

  34. Question 34 of 60 Operations using DataFrame Medium

    A DataFrame has columns department and salary. Which expression calculates the average salary for each department?

  35. Question 35 of 60 Operations using DataFrame Medium

    Which expression removes only rows where the email value is missing, regardless of missing values in other columns?

  36. Question 36 of 60 Operations using DataFrame Medium

    Which statement replaces missing values in the score column with that column's median while leaving other columns unchanged?

  37. Question 37 of 60 DataFrame Medium

    Which expression renames the column old_name to new_name without renaming any index labels?

  38. Question 38 of 60 Operations using DataFrame Medium

    DataFrames customers and orders both contain customer_id. Which expression keeps only IDs present in both DataFrames?

  39. Question 39 of 60 Series Medium

    A Series colors contains ['red', 'blue', 'red', 'green', 'blue', 'red']. What does colors.value_counts() return first by default?

  40. Question 40 of 60 Operations using DataFrame Medium

    Two DataFrames jan and feb have identical columns but overlapping index labels. Which expression stacks their rows and creates a fresh sequential index?

  41. Question 41 of 60 Introduction to pandas Hard

    Given:

    left = pd.Series([10, 20], index=["a", "b"])

    right = pd.Series([1, 2], index=["b", "c"])

    What is (left + right).fillna(0).to_dict()?

  42. Question 42 of 60 Series Hard

    Consider s = pd.Series([3, 1, 2], index=["x", "y", "x"]). Which statement about r = s["x"] is correct?

  43. Question 43 of 60 Series Hard

    Given s = pd.Series([1, pd.NA, 3], dtype="Int64") and r = s * 2, which pair correctly describes r?

  44. Question 44 of 60 DataFrame Hard

    Given:

    p = pd.Series([1, 2], index=["a", "b"])

    q = pd.Series([3, 4], index=["b", "c"])

    df = pd.DataFrame({"p": p, "q": q})

    Which result is correct?

  45. Question 45 of 60 DataFrame Hard

    Given:

    df = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=["x", "y"])

    df.loc[:, ["a", "b"]] = df.loc[:, ["b", "a"]]

    What are the final columns a and b?

  46. Question 46 of 60 DataFrame Hard

    Given:

    df = pd.DataFrame({"v": [10, 20, 30]}, index=["a", "b", "c"])

    mask = pd.Series([True, False, True], index=["c", "a", "b"])

    What is df.loc[mask].index.tolist()?

  47. Question 47 of 60 Sorting Hard

    For the DataFrame below, what is the resulting id order after df.sort_values(["a", "b"], ascending=[True, False], na_position="first")?

    df = pd.DataFrame({"id": [0, 1, 2, 3], "a": [2, 1, 1, np.nan], "b": [1, 2, 1, 0]})

  48. Question 48 of 60 Sorting Hard

    Given:

    df = pd.DataFrame({"id": [0, 1, 2], "a": [-2, 1, -1], "b": [1, -3, 2]})

    What is the id order produced by df.sort_values(["a", "b"], key=lambda s: s.abs())?

  49. Question 49 of 60 Sorting Hard

    A DataFrame must be sorted by one column while preserving the original relative order of rows with equal keys. Which call explicitly provides that stability?

  50. Question 50 of 60 Working with CSV files Hard

    A CSV contains:

    id,value\n001,NA\n002,\n003,null\n

    Which call preserves the IDs' leading zeros and reads all three value fields as literal strings rather than missing values?

  51. Question 51 of 60 Working with CSV files Hard

    A CSV has columns in the order a,b,c. What column order is normally produced by pd.read_csv(path, usecols=["c", "a"])?

  52. Question 52 of 60 Working with CSV files Hard

    Suppose chunks is a list of DataFrames read from one CSV using chunksize, and chunk sizes differ. Which expression computes the exact overall mean of numeric column x, ignoring missing values?

  53. Question 53 of 60 Working with CSV files Hard

    Given the CSV text a,b\n1,10\n2,20\n3,30\n, what is the sum of column a after calling pd.read_csv(io.StringIO(text), skiprows=lambda i: i == 2)?

  54. Question 54 of 60 Operations using DataFrame Hard

    Given:

    df = pd.DataFrame({"x": [1, 2], "y": [10, 20]}, index=["a", "b"])

    s = pd.Series([100, 200], index=["b", "a"])

    r = df.add(s, axis="index")

    What is r.loc["a"].tolist() + r.loc["b"].tolist()?

  55. Question 55 of 60 Operations using DataFrame Hard

    A left DataFrame has join keys [1, 1, 2], while the right DataFrame has unique join keys [1, 2]. What is the most restrictive validate mode that permits left.merge(right, on="key", validate=...)?

  56. Question 56 of 60 Operations using DataFrame Hard

    Given:

    a = pd.DataFrame({"x": [1, 2]}, index=["u", "v"])

    b = pd.DataFrame({"y": [3, 4]}, index=["v", "w"])

    What describes pd.concat([a, b], axis=1, join="inner")?

  57. Question 57 of 60 Operations using DataFrame Hard

    Given:

    df = pd.DataFrame({"g": ["A", "A", "B"], "x": [1, 3, 10]})

    What is df[df["x"] > df.groupby("g")["x"].transform("mean")]["x"].tolist()?

  58. Question 58 of 60 Operations using DataFrame Hard

    A DataFrame contains two rows with the same id and key pair but values 10 and 20. What happens when these columns are reshaped with df.pivot(index="id", columns="key", values="value")?

  59. Question 59 of 60 Operations using DataFrame Hard

    Given df = pd.DataFrame({"a": [1, np.nan], "b": [np.nan, np.nan]}), what does df.sum(min_count=1) contain?

  60. Question 60 of 60 Operations using DataFrame Hard

    Given:

    df = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=["x", "y"])

    other = pd.DataFrame({"a": [9, 8], "b": [np.nan, 7]}, index=["y", "z"])

    After df.update(other), what is df.loc["y"].tolist()?

That's unit 9

Answer a few questions and your score shows up here.