Practice Create a New Column
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Easy#2881
LeetCode ProblemCreate a New Column
Problem Statement
The employees DataFrame has name (object) and salary (int) columns. Add a bonus column containing twice each row's salary, keeping the existing columns. Return the updated DataFrame.
Source: Create a New Column on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
DataFrame employees +---------+--------+ | name | salary | +---------+--------+ | Piper | 4548 | | Grace | 28150 | | Georgia | 1103 | | Willow | 6593 | | Finn | 74576 | | Thomas | 24433 | +---------+--------+
Output
+---------+--------+--------+ | name | salary | bonus | +---------+--------+--------+ | Piper | 4548 | 9096 | | Grace | 28150 | 56300 | | Georgia | 1103 | 2206 | | Willow | 6593 | 13186 | | Finn | 74576 | 149152 | | Thomas | 24433 | 48866 | +---------+--------+--------+
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.