English

Create the following series and do the specified operation: MonthDays, from a numpy array having the number of days in the 12 months of a year. The labels should be the month numbers from 1 to 12.

Advertisements
Advertisements

Question

Create the following series and do the specified operation:

MonthDays, from a numpy array having the number of days in the 12 months of a year. The labels should be the month numbers from 1 to 12.

Code Writing
Advertisements

Solution

import pandas as pd
import numpy as np
MonthDays = pd.Series(np.array([31,28,31,30,31,30,31,31,30,31,30,31]), 
                      index=range(1,13))
print(MonthDays)

Output:

1 31
2 28
3 31
4 30
5 31
6 30
7 31
8 31
9 30
10 31
11 30
12 31
dtype int64
shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Data Handling using Pandas - I - Exercise [Page 60]

APPEARS IN

NCERT Informatics Practices [English] Class 12
Chapter 2 Data Handling using Pandas - I
Exercise | Q 5. e) | Page 60
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×