Which of the following is the standard alias used to import pandas?
Data Handling using Pandas — Important Questions
SUMMARY: This chapter focuses on data manipulation and analysis using the Pandas library in Python.
KEY TOPICS: Pandas DataFrame, Pandas Series, data cleaning, data aggregation, data visualization, handling missing data, merging and joining data, groupby operations, reading and writing data files, data transformation.
A 1-D labelled array in pandas is called a:
Check answerHide answer
A 2-D tabular data structure in pandas is called a:
Check answerHide answer
Which method is used to view the first 5 rows of a DataFrame?
Check answerHide answer
Which attribute returns the number of rows and columns in a DataFrame?
Check answerHide answer
Differentiate between Series and DataFrame in pandas with two points each.
Write Python code to create a Series of marks for 5 students.
Write Python code to create a DataFrame from a dictionary.
How can you read a CSV file into a DataFrame? Write the code.
Differentiate between iloc and loc indexers in pandas.
Write a Python program using pandas to create a DataFrame of 5 students with name marks and grade then display students with marks > 75.
Discuss any five DataFrame methods (head info describe shape columns) with examples.
Write Python code to add a new column 'percentage' to a DataFrame containing marks of 5 subjects.
Discuss aggregation functions in pandas (sum mean max min count) with examples.
Write Python code to read a CSV file containing employee data and print only employees with salary > 50000.
Differentiate between Series and DataFrame in pandas in tabular form on five features.
Assertion (A): Pandas is built on top of NumPy.
Reason (R): It uses NumPy arrays internally for performance.
Show explanationHide explanation
Assertion (A): A Series can be created from a list dictionary or NumPy array.
Reason (R): Each element gets a default integer index unless specified.
Show explanationHide explanation
Assertion (A): DataFrames can have heterogeneous data types.
Reason (R): Different columns can hold different data types.
Show explanationHide explanation
Assertion (A): The describe() method gives statistical summary.
Reason (R): It includes count mean std min max and quartiles.
Show explanationHide explanation
Assertion (A): The drop() method can remove rows or columns.
Reason (R): The axis parameter specifies the direction (0 = rows 1 = columns).
Show explanationHide explanation
Statement 1: A Series is one-dimensional.
Statement 2: A DataFrame is two-dimensional.
Show answerHide answer
Statement 1: iloc uses integer position-based indexing.
Statement 2: loc uses label-based indexing.
Show answerHide answer
Statement 1: head(n) returns the first n rows of a DataFrame.
Statement 2: tail(n) returns the last n rows.
Show answerHide answer
Statement 1: read_csv() loads CSV data into a DataFrame.
Statement 2: to_csv() writes a DataFrame to a CSV file.
Show answerHide answer
Statement 1: fillna() replaces missing values.
Statement 2: dropna() removes rows or columns containing missing values.
Show answerHide answer
-
A 2-D tabular data structure in pandas is a:ASeriesBDataFrameCIndexDTuple
-
Which method loads a CSV file into a DataFrame?Aread_csv()Bread_table()Cread_excel()Dload_csv()
-
Write the complete pandas program to compute averages identify the topper and list failing students.
Show answersHide answers
Match each pandas object with its dimensionality and creator.
| Object | Dimensions | How to create |
|---|---|---|
| Series | ? | ? |
| DataFrame | ? | ? |
| Index | ? | ? |
For DataFrame df with 5 students predict each operation's result.
| Method/attribute | Returns |
|---|---|
| df.head() | ? |
| df.tail() | ? |
| df.shape | ? |
| df.columns | ? |
| df.describe() | ? |
| df.info() | ? |
Match each pandas method with its purpose.
| Method | Purpose |
|---|---|
| read_csv() | ? |
| dropna() | ? |
| fillna() | ? |
| groupby() | ? |
| sort_values() | ? |
| merge() | ? |
Predict the result of each pandas Series operation.
| Operation on s = [10, 20, 30, 40] | Result |
|---|---|
| s[0] | ? |
| s.sum() | ? |
| s.mean() | ? |
| s.max() | ? |
| len(s) | ? |
| s + 5 | ? |
Study the pandas DataFrame structure and answer:
-
A 2-D labelled tabular data structure is called a:ASeriesBDataFrameCIndexDList
-
The shape of the DataFrame shown is:A(4, 5)B(5, 4)C(4, 4)D(5, 5)
-
Discuss the structure of a pandas DataFrame and any three common attributes/methods.
Show answersHide answers
Study the pandas Series structure and answer:
-
A 1-D labelled array in pandas is called a:ASeriesBDataFrameCIndexDList
-
For s = pd.Series([78, 65, 92, 84, 55]) what is s[2]?A78B65C92D55
-
Discuss the structure and common operations of a pandas Series.
Show answersHide answers
Study the DataFrame workflow diagram and answer:
-
Which method loads a CSV file into a DataFrame?Aread_csv()Bopen()Cload()Dimport_csv()
-
Which methods are commonly used in DataFrame processing?Adropna()Bfillna()Cgroupby()DAll of these
-
Discuss the typical workflow for processing data with pandas DataFrames.
Show answersHide answers
Make a full Informatics Practices paper on Data Handling using Pandas.
Pick the question mix, set the marks, hit generate. You get a ready-to-print paper with an answer key.
Generate your paper — free