Completed
Pandas Introduction + Series Creation
Questions From This Challenge
Q1mcq1 mark
Which import statement is the standard convention used to bring the Pandas library into a Python program?
import pandas as pd ✓
import pandas as np
include pandas as pd
from pandas import *
Q2mcq1 mark
Pandas is built on top of which Python library for its underlying array operations?
NumPy ✓
Matplotlib
Tkinter
Requests
Q3mcq1 mark
Which Pandas data structure is a one-dimensional labeled array capable of holding data of a single type?
Series ✓
DataFrame
Panel
Index
Q4mcq1 mark
When a Series is created from a Python list without specifying an index, what does Pandas use as the default index?
Integer positions starting from 0 ✓
The list's values themselves
Alphabetical labels a, b, c, ...
No index is created
Q5mcq1 mark
When a Series is created from a dictionary, what becomes the index of the resulting Series?
The dictionary's keys ✓
The dictionary's values
A default RangeIndex of integers
The dictionary's keys sorted in reverse order
Q6mcq1 mark
Which statement correctly creates a Pandas Series where the scalar value 5 is repeated for every label in the index ['a', 'b', 'c']?
pd.Series(5, index=['a', 'b', 'c']) ✓
pd.Series(['a', 'b', 'c'], 5)
pd.Series(index=5, data=['a', 'b', 'c'])
pd.Series([5, 5, 5, 5])
Q7mcq1 mark
What is the primary purpose of the Matplotlib library when used alongside Pandas?
To create visual plots and charts of data ✓
To read and write CSV files
To perform statistical hypothesis testing
To manage database connections
Q8mcq1 mark
Which of the following function calls draws a bar graph using Matplotlib?
plt.bar() ✓
plt.pie()
plt.scatter()
plt.box()
Q9mcq1 mark
Which import statement is required before creating a NumPy ndarray to use as the data source for a Pandas Series?
import numpy as np ✓
import numpy as pd
import array as np
include numpy as np
Q10mcq1 mark
Given a NumPy ndarray arr = np.array([1, 2, 3]), which line of code correctly creates a Series from arr with the custom index ['x', 'y', 'z']?
pd.Series(arr, index=['x', 'y', 'z']) ✓
pd.Series(index=arr, data=['x', 'y', 'z'])
pd.Series(['x', 'y', 'z'], arr)
pd.Series.create(arr, ['x', 'y', 'z'])
Q11output1 mark
What is the output of the following code, which creates a Series from a plain Python list?
import pandas as pd s = pd.Series([10, 20, 30]) print(s)
Correct output:
0 10
1 20
2 30
dtype: int64Q12output1 mark
What is the output of the following code, which creates a Series from a dictionary?
import pandas as pd
d = {'a': 100, 'b': 200, 'c': 300}
s = pd.Series(d)
print(s)
Correct output:
a 100
b 200
c 300
dtype: int64Q13output1 mark
What is the output of the following code, which creates a Series from a scalar value?
import pandas as pd s = pd.Series(5, index=['x', 'y', 'z']) print(s)
Correct output:
x 5
y 5
z 5
dtype: int64Q14output1 mark
What is the output of the following code, which creates a Series from a NumPy ndarray with a custom index?
import pandas as pd import numpy as np arr = np.array([1, 2, 3, 4]) s = pd.Series(arr, index=['p', 'q', 'r', 's']) print(s)
Correct output:
p 1
q 2
r 3
s 4
dtype: int64Q15output1 mark
What is the output of the following code, where an explicit index list is supplied along with a dictionary that does not contain all of those labels?
import pandas as pd
d = {'a': 1, 'b': 2, 'c': 3}
s = pd.Series(d, index=['b', 'c', 'd'])
print(s)
Correct output:
b 2.0
c 3.0
d NaN
dtype: float64