What is the output of the following? import pandas as pd S1 = pd.Series([100,…

2023

What is the output of the following? import pandas as pd S1 = pd.Series([100, 200, 300]) print(S1)

  1. A.

    1 100

    2 200

    3 300

    dtype: int64

  2. B.

    0 100

    1 200

    2 300

    dtype: float64

  3. C.

    1 100

    2 200

    3 300

    dtype: float64

  4. D.

    0 100

    1 200

    2 300

    dtype: int64

Attempted by 1280 students.

Show answer & explanation

Correct answer: D

Correct output:

  • 0 100

  • 1 200

  • 2 300

  • dtype: int64

Why: A Pandas Series created from a Python list uses 0-based integer indexing by default (so indices are 0, 1, 2). All provided values are integers, so Pandas infers the dtype as int64.

Common mistakes:

  • Assuming indexing starts at 1 (this is not the case for a default Series).

  • Expecting dtype float64 when all values are integers; dtype would be float64 only if values were floats or mixed types requiring upcasting.

Explore the full course: Bpsc