Question: 4 . Convert the following data dictionary into DataFrame df representing a student record data = { 'StudentID': [ 1 0 1 , 1

4. Convert the following "data" dictionary into DataFrame df representing a student record
data =\{ 'StudentID': [101,102,103,104,105,106], 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve', 'Frank'], 'Math': [85,70,90,65,95,88], 'English': [78,82,88,75,92,80], 'Science': [92,81,85,89,78,85], 'History': [75,85,82,80,70,88]\}
Execute the following code after you create the dataframe ' df ',
df.set_index('StudentID', inplace=True)
Perform the following tasks below using Index operations and methods. (25 points)
a. Add a new index pd.Index \(([107,108])\) to the df.index, representing two additional student IDs. Show the updated Index and note the resulting Index structure.
b. Create a new Index pd.Index \(([101,103,107])\) and find the difference between df.index and this new Index. List any student IDs that exist in the original DataFrame Index but not in the new Index.
c. Create another Index pd.Index ([102,103,106,108]). Find the intersection and union of df.index and this new Index. Print the resulting Indexes.
d. Using the original df.index, check if each student ID is part of pd.Index([101,105,107,109]). Display the Boolean array resulting from this operation.
e. Remove the student with ID 104 from the Index. Show the updated Index and confirm the deletion.
f. Insert a new student ID 110 at position 3 in df.index. Display the modified Index.
g. Determine if df.index is unique and if it is monotonically increasing. Provide a Boolean result for each.
h. Print the unique values in the df.index and explain if any duplicates were found.
4 . Convert the following "data" dictionary into

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!