1.

Mr. Ankit is working in an organisation as data analyst. He uses Python Pandas and Matplotlib for the same. He got a dataset of the passengers for the year 2010 to 2012 for January, March and December. His manager wants certain information from him, but he is facing some problems. Help him by answering few questions given below:   Year   MonthPassengers02010Jan2512010Mar5022012Jan3532010Dec5542012Dec65Code to create the above data frame: import pandas as ............ #Statement 1 data={"Year":[2010,2010,2012,2010,2012],"Month":["Jan","Mar","Jan","Dec","Dec"] ,"Passengers":[25,50,35,55,65]}df=pd..............(data)  #Statement 2print(df)  i. Choose the right code from the following for statement 1. i. pd ii. df iii. data iv. p ii. Choose the right code from the following for the statement 2. i. Data frame ii. Data Frame iii. Seriesiv. Dictionaryiii. Choose the correct statement/ method for the required output: (5,3) i. df.index ii. df.shape() iii. df.shape iv. df.sizeiv. He wants to print the details of "January" month along with the number of passengers, Identify the correct statement:MonthPassengers0Jan252Jan35i. df.loc[['Month','Passengers']][df['Month']=='Jan'] ii. df[['Month','Passengers']][df['Month']=='Jan'] iii. df.iloc[['Month','Passengers']][df['Month']=='Jan'] iv. df(['Month','Passengers']][df['Month']=='Jan') [df['Month']=='Jan'] v. Mr. Ankit wants to change the index of the Data Frame and the output for the same is given below. Identify the correct statement to change the index.YearMonthPassengersAir India2010Jan25Indigo2010Mar50Spicejet2012Jan35Jet2010Dec55Emirates2012Dec65i. df.index[]=["Air India","Indigo","Spicejet","Jet","Emirates"]ii. df.index["Air India","Indigo","Spicejet","Jet","Emirates"]iii. df.index=["Air India","Indigo","Spicejet","Jet","Emirates"]iv. df.index()=["Air India","Indigo","Spicejet","Jet","Emirates"]

Answer»

i. (i) pd

ii. (ii) Data Frame

iii. (iii) df.shape

iv. (ii) df[['Month','Passengers']][df['Month']=='Jan']

v. (iii) df.index=["Air India","Indigo","Spicejet","Jet","Emirates"]



Discussion

No Comment Found

Related InterviewSolutions