Practice Rename Columns
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Easy#2885
LeetCode ProblemRename Columns
Problem Statement
The students DataFrame has id (int), first (object), last (object) and age (int) columns. Rename them to student_id, first_name, last_name and age_in_years respectively, retaining their data, and return the resulting DataFrame.
Source: Rename Columns on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
+----+---------+----------+-----+ | id | first | last | age | +----+---------+----------+-----+ | 1 | Mason | King | 6 | | 2 | Ava | Wright | 7 | | 3 | Taylor | Hall | 16 | | 4 | Georgia | Thompson | 18 | | 5 | Thomas | Moore | 10 | +----+---------+----------+-----+
Output
+------------+------------+-----------+--------------+ | student_id | first_name | last_name | age_in_years | +------------+------------+-----------+--------------+ | 1 | Mason | King | 6 | | 2 | Ava | Wright | 7 | | 3 | Taylor | Hall | 16 | | 4 | Georgia | Thompson | 18 | | 5 | Thomas | Moore | 10 | +------------+------------+-----------+--------------+
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.