0% found this document useful (0 votes)
10 views2 pages

Dataframe

The document is a comprehensive question bank focused on DataFrames in Python, featuring multiple choice, short answer, extended response, and coding questions. It covers key concepts such as the Pandas library, DataFrame creation, data handling, and operations like merging and reshaping. Additionally, it includes practical coding exercises to reinforce understanding of DataFrame manipulation and analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Dataframe

The document is a comprehensive question bank focused on DataFrames in Python, featuring multiple choice, short answer, extended response, and coding questions. It covers key concepts such as the Pandas library, DataFrame creation, data handling, and operations like merging and reshaping. Additionally, it includes practical coding exercises to reinforce understanding of DataFrame manipulation and analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exploring DataFrames in Python: A Comprehensive

Question Bank
Multiple Choice Questions
1. What Python library is commonly used to work with DataFrames?
a) NumPy
b) Pandas
c) Matplotlib
d) SciPy
2. Which of the following best describes a DataFrame?
a) A one-dimensional labeled array
b) A two-dimensional labeled data structure
c) A three-dimensional array
d) A dictionary of lists
3. How do you create a DataFrame from a dictionary in Python?
a) pd.DataFrame(dict)
b) DataFrame.from_dict(dict)
c) create_dataframe(dict)
d) dict_to_dataframe(dict)
4. What method is used to display the first few rows of a DataFrame?
a) show()
b) display()
c) head()
d) preview()
5. Which of the following is NOT a valid way to select a column in a DataFrame?
a) df['column_name']
b) df.column_name
c) df[['column_name']]
d) df.select('column_name')
Short Answer Questions
1. Explain the difference between a Series and a DataFrame in Python.
2. How can you handle missing data in a DataFrame? Provide two methods.
3. Describe the purpose of the groupby() function in Pandas and give an example of
its use.
4. What is the significance of indexing in DataFrames? How does it differ from regular
Python lists?
5. Explain how you would merge two DataFrames in Python. What are some potential
issues to consider?
Extended Response Questions
1. You have a large DataFrame containing sales data for a company. Describe the steps
you would take to analyze this data, including data cleaning, aggregation, and
visualization. Provide example code snippets where appropriate.
2. Compare and contrast the use of DataFrames in Python with other data structures
like lists and dictionaries. In what scenarios would you choose to use a DataFrame
over these other options?
3. Explain the concept of data reshaping in Pandas. Describe the differences between
wide and long format data, and provide examples of when you might need to
convert between these formats.
4. You're working with a DataFrame that contains time series data. How would you
handle date and time operations in Pandas? Discuss methods for resampling, rolling
calculations, and handling time zones.
5. Describe the process of applying a custom function to a DataFrame using apply() or
applymap(). Provide an example scenario where this might be useful in data
analysis or manipulation.
Coding Questions
1. Write a Python code snippet to create a DataFrame from a dictionary containing
information about students (name, age, grade).
2. Given a DataFrame df with columns 'A', 'B', and 'C', write code to:
a) Select all rows where 'A' is greater than 5
b) Calculate the mean of column 'B'
c) Sort the DataFrame by column 'C' in descending order
3. Create a code snippet that demonstrates how to handle missing values in a
DataFrame, including methods to identify, fill, and drop null values.
4. Write a function that takes a DataFrame as input and returns a new DataFrame with
the following transformations:
○ Convert all string columns to uppercase
○ Multiply all numeric columns by 2
○ Add a new column 'processed' with the value True for all rows
5. Demonstrate how to perform a groupby operation on a DataFrame, calculating the
mean and sum for numeric columns within each group. Use a hypothetical dataset of
your choice.
Remember to review and test your answers, especially for the coding questions, to ensure
accuracy and proper functionality within a Python environment using Pandas.

You might also like