Pandas Assignment
Pandas Assignment
support@intellipaat.com
+91-7022374614
11. Which of the following data types can a Pandas Series have?
A. Int
B. Str
C. Float
D. All of the above
13. What value will you get on the left side after printing a series format data?
A. Data
B. Value
C. Index
D. All of the above
15. In what format the keys will get converted into when we convert the dictionary data into
data frame format?
A. Rows
B. Columns
C. Indexes
D. Records
A. data.apply(your_function_name(arg1))
B. data.apply_fun(function_name())
C. data.app(data)
D. None of the above
18. Which of the following code will help to display the 3rd, 4th and 5th rows from the 6th to 9th
columns of data frame data?
A. data.loc[3:6, 6:10]
B. data.iloc[3;6,6;10]
C. data.iloc[3:6,6:10]
D. None of the above
19. Which of the following syntax will display the last two records of df?
import pandas as pd
A. df.iloc[:'r3']
B. df.loc['r2':'r3']
C. df.iloc['r2':'r3']
D. df.loc[:'r3']
20. Which of the following is/are true about loc in pandas:
21. Change the date column in the format (dd/mm/year) using the pandas to_datetime()
Function.
A. pd.to_datetime(data['date'], format='%Y-%m-%d', utc=False, dayfirst=True)
B. pd.to_datetime(data['date'])
C. pd.to_datetime(data['dates'], format='%Y-%m-%d', utc=False, dayfirst=True)
D. pd.to_datetime(data['date'])
22. Create a separate data frame that satisfies the conditions below.
1. Houses built before 1980
2. Have more than 2 bedrooms
3. Have more than 2 floors.
A. data.loc[(data["yr_built"] > 1980) & (data['floors'] > 2) & (data['bedrooms'] > 2)]
B. data.loc[(data["yr_built"] < 1980) & (data['floors'] > 2) & (data['bedrooms'] > 2)]
C. data.loc[(data["yr_built"] | 1980) & (data['floors'] > 2) | (data['bedrooms'] > 2)]
D. data.loc[(data["yr_built"] < 1980) | (data['floors'] > 2) | (data['bedrooms'] < 2)]
23. For a given nested list, convert the same into a dataframe.
sample_list = [['Carl', 22],
['Martha', 25],
['Calvin', 12],
['Stuart', 15]
]
The resulting dataframe must contain the column names as ‘Name’, and ‘Age’ with the
respective values from the sample_list.
A. pd.DataFrame(sample_list)
B. pd.DataFrame(sample_list, column_names=['Name', 'Age'])
C. pd.DataFrame(sample_list, columns=['Name', 'Age'])
D. pd.DataFrame(sample_list, column_name=['Name', 'Age'])
26. Create a separate dataframe that contains houses ordered in ascending or descending
order of the prices of each house.
A. ascending = housing.sort_values('price', ascending=False)
descending = housing.sort_values('price', ascending=False)
B. ascending = housing.sort_values('price', ascending=True)
descending = housing.sort_values('price', ascending=False)
C. ascending = housing.sort_values('price', ascending=False)
descending = housing.sort_values('price', ascending=True)
D. ascending = housing.sort_values('price', ascending=True)
descending = housing.sort_values('price', ascending=True)
27. Calculate the mean and standard deviation of all the numerical values in the dataset. For
example - the mean for the bedrooms column is 3.370 and the standard deviation is 0.930.
A. housing.describe()
B. housing.info()
C. housing.corr()
D. housing.std()
29. Create a new column with the floor area(sqft_living, sqft_lot, sqft_above, sqft_basement, all
combined in one column).
A. data['Floor Area'] = data['sqft_living'], data['sqft_lot'], data['sqft_basement'],
data['sqft_above']
B. df['Floor Area'] = data['sqft_living'] + data['sqft_lot'] + data['sqft_basement'] +
data['sqft_above']
C. data['Floor Area'] = data['sqft_living', 'sqft_lot','sqft_basement','sqft_above']
D. data['Floor Area'] = data['sqft_liv', 'sqft_lot','sqft_base','sqft_above']
31. What will be the correlation between the columns sqft_living and sqft_above?
A. 0.702035
B. 0.754665
C. 0.876597
D. 0.303093
32. If the correlation between the columns bathrooms and sqft_living is 0.754665, what all
interpretations can be made about the two columns?
A. A positive correlation between the two columns
B. The columns show perfect correlation.
C. A strong negative correlation between the two columns
D. No correlation between the two columns.