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

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

A.

1 100 2 200 3 300 dtype: int64

B.

0 100 1 200 2 300 dtype: float64

C.

1 100 2 200 3 300 dtype: float64

D.

0 100 1 200 2 300 dtype: int64

Correct option is D


The given code creates a Pandas Series from a list [100, 200, 300] and prints it.
import pandas as pd
S1 = pd.Series([100, 200, 300])
print(S1)
· The pd.Series() function automatically assigns an integer index starting from 0 to the elements of the list.
· Since no other index is specified, the default index is used: 0, 1, 2.
· The elements [100, 200, 300] are interpreted as integer values.
· The dtype will be int64 because the elements are integers.
Thus, the output will be:
0 100
1 200
2 300
dtype: int64
Important Key Points:
1. pd.Series(): This function creates a one-dimensional array-like object, with a default integer index starting from 0.
2. dtype: Since the input data is a list of integers, the data type of the resulting series is int64.
3. Default Indexing: When no custom index is specified, Pandas automatically assigns a default index starting from 0.
Knowledge Booster:
· Option (a): This is incorrect because the index starts at 0 by default, not 1.
· Option (b): This is incorrect because the default data type for integers is int64, not float64.
· Option (c): This is incorrect because the index should start at 0, not 1, and the data type is int64, not float64.

Free Tests

Free
Must Attempt

UPTET Paper 1: PYP Held on 23rd Jan 2022 (Shift 1)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Social Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Maths & Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
test-prime-package

Access ‘EMRS PGT’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow