You're a data scientist who just received student information in the form of a 2D list. Your task is to transform this raw data into a properly structured pandas DataFrame for further analysis.
Given a 2D list called student_data where each inner list contains exactly two elements:
- The first element is the student ID
- The second element is the student's age
Create a DataFrame with two columns: student_id and age. The DataFrame should preserve the exact same order as the original 2D list.
Example:
Input: [[1, 15], [2, 11], [3, 11], [4, 20]]
Output: A DataFrame with columns 'student_id' and 'age' containing the respective values.
Input & Output
Visualization
Time & Space Complexity
Pandas internally processes each row once to create the DataFrame, where n is the number of students
Space is used to store the DataFrame structure and data, no additional intermediate storage needed
Constraints
- 1 โค len(student_data) โค 103
- Each inner list contains exactly 2 elements: [student_id, age]
- 1 โค student_id โค 106
- 1 โค age โค 150
- student_data is guaranteed to be a valid 2D list