2885. Rename Columns
Description
DataFrame students +-------------+--------+ | Column Name | Type | +-------------+--------+ | id | int | | first | object | | last | object | | age | int | +-------------+--------+
Write a solution to rename the columns as follows:
id
tostudent_id
first
tofirst_name
last
tolast_name
age
toage_in_years
The result format is in the following example.
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 | +------------+------------+-----------+--------------+ Explanation: The column names are changed accordingly.
Solutions
Solution 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|