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

CDP Subject Test 01

languageIcon English
  • pdpQsnIcon20 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt

EVS Subject Test 01

languageIcon English
  • pdpQsnIcon20 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt

CTET Paper-I PYP (07 July 2024)

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
289k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow