Skip to content
Question

Q.(a) Niharika wants to create a Pandas Series using a NumPy array with three elements 'a', 'b', and 'c', and assign custom indexes 'first', 'second' and 'third'. Help her complete the code below. import pandas as pd import ______ as np arr = np._____ (['a' , 'b' , 'c']) s = pd.(arr,=['first','second','third']) print(s)

(OR)
(b) Write the output of the following code : import pandas as pd s1 = pd.Series ([1, 2, 3], index = ['a','b','c']) s2 = pd.Series ([4, 5, 6], index = ['b','c','d']) print(s1 + S2)
CBSECBSE Class XII Board 2026Subjective· 2mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): the blanks are numpy, array, Series, index; the Series prints a,b,c against first/second/third with dtype object.

Part (b): Series addition aligns on index labels — b=6.0, c=8.0, and the unmatched a,d become NaN (float64).

Part (a)

The code builds a NumPy array and wraps it in a labelled Pandas Series, so the four blanks are:

  • numpy — the module imported as np.
  • array — np.array(...) creates the array from the list.
  • Series — pd.Series(...) builds the Series.
  • index — the parameter that supplies the custom labels.
import pandas as pd
import numpy as np
arr = np.array(['a', 'b', 'c'])
s = pd.Series(arr, index=['first', 'second', 'third'])
print(s)

Expected output:

first     a
second    b
third     c
dtype: object
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.