Questions

3 Marks Each

🎯

Test yourself on this topic

9 questions · timed · auto-graded

Question 13 Marks
Write a program that reads from a CSV file where the separator character is "$". Read only first 5 rows of the dataframe.

Give column headings as Item Name, Quantity, Price.

Make sure to read first row as data and not as column headers.

Answer
import pandas as pd

df = pd.read_csv ("data.csv", sep = "$", names = ["Item

Name", "Quantity", "Price"), header = None, rows 35)

print(df)

View full question & answer
Question 23 Marks
What is the purpose of sqlalchemylibrary?
Answer
It is the library which helps us to communicate between python programs and databases.
View full question & answer
Question 33 Marks
How to get the items not common to both series A and series B?
Answer
We get all the items of p1 and p2 not common to both using below example:

View full question & answer
Question 43 Marks
How to get the items of series A not present in series B?
Answer
We can remove items present in p2 from p1 using isin() method.

View full question & answer
Question 53 Marks
How to iterate over a Pandas DataFrame?
Answer
You can iterate over the rows of the DataFrame by using for loop in combination with an iterrows() call on the DataFrame or iteritems().
View full question & answer
Question 63 Marks
What is Vectorization in Python pandas?
Answer
Vectorization is the process of running operations on the entire array. This is done to reduce the amount of iteration performed by the functions. Pandas have a number of vectorized functions like aggregations, and string functions that are optimized to operate specifically on series and DataFrames. So it is preferred to use the vectorized pandas functions to execute the operations quickly
View full question & answer
Question 73 Marks
How can you get the sum of values of a column in pandas DataFrame?
Answer
Pandas dataframe.sum() function return the sum of the values for the requested axis. If the input is index axis then it adds all the values in a column and repeats the same for all the columns and returns a series containing the sum of all the values in each column. It also provides support to skip the missing values in the dataframe while calculating the sum in the dataframe.
View full question & answer
Question 83 Marks
How to write a pandas dataframe to a file and when it is used?
Answer
When you have done your data munging and manipulation with Pandas, you might want to export the DataFrame to another format. This section will cover two ways of outputting your DataFrame: to a CSV or to an Excel file.

Outputting a DataFrame to CSV To output a Pandas DataFrame as a CSV file, you can use to_csv().

View full question & answer
Question 93 Marks
Explain the concept of split-apply-combin in group by.
Answer
By “group by” we are referring to a process involving one or more of the following steps:

Splitting the data into groups based on some criteria.

Applying a function to each group independently.

Combining the results into a data structure.

View full question & answer
3 Marks Each - Computer Science STD 12 Commerce Questions - Vidyadip