Question:

Write a Python program to create and display a Pandas Series as shown below:

July31
Aug31
Sept30
Oct31

The index labels are the names of the months – July, Aug, Sept, Oct.

The corresponding scalar values are the number of days in these respective months – 31, 31, 30, 31.

Show Hint

Import pandas and call pd.Series with the list [31, 31, 30, 31] and the index list of month names, then print it.
Updated On: Oct 20, 2026
Show Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Understand the target Series:
The Series has four values 31, 31, 30 and 31. Its index labels are the month names July, Aug, Sept and Oct. We must create the Series and then display it.

Step 2: Plan the program:
First import the Pandas library.
Then call pd.Series with a list of values and an index list of the same length.
Then print the Series.

Step 3: Write the program:
import pandas as pd
S = pd.Series([31, 31, 30, 31], index=['July', 'Aug', 'Sept', 'Oct'])
print(S)


Step 4: Output checked by running the code:
July    31
Aug     31
Sept    30
Oct     31
dtype: int64

The values are whole numbers, so Pandas shows the dtype as int64.

Final Answer:
The three-line program above creates and displays the required Series.
Was this answer helpful?
0
0