mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-08 08:51:42 +08:00
update
This commit is contained in:
45
leetcode/problem/create-a-new-column.html
Normal file
45
leetcode/problem/create-a-new-column.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<pre>
|
||||
DataFrame <code>employees</code>
|
||||
+-------------+--------+
|
||||
| Column Name | Type. |
|
||||
+-------------+--------+
|
||||
| name | object |
|
||||
| salary | int. |
|
||||
+-------------+--------+
|
||||
</pre>
|
||||
|
||||
<p>A company plans to provide its employees with a bonus.</p>
|
||||
|
||||
<p>Write a solution to create a new column name <code>bonus</code> that contains the <strong>doubled values</strong> of the <code>salary</code> column.</p>
|
||||
|
||||
<p>The result format is in the following example.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong>
|
||||
DataFrame employees
|
||||
+---------+--------+
|
||||
| name | salary |
|
||||
+---------+--------+
|
||||
| Piper | 4548 |
|
||||
| Grace | 28150 |
|
||||
| Georgia | 1103 |
|
||||
| Willow | 6593 |
|
||||
| Finn | 74576 |
|
||||
| Thomas | 24433 |
|
||||
+---------+--------+
|
||||
<strong>Output:</strong>
|
||||
+---------+--------+--------+
|
||||
| name | salary | bonus |
|
||||
+---------+--------+--------+
|
||||
| Piper | 4548 | 9096 |
|
||||
| Grace | 28150 | 56300 |
|
||||
| Georgia | 1103 | 2206 |
|
||||
| Willow | 593 | 13186 |
|
||||
| Finn | 74576 | 149152 |
|
||||
| Thomas | 24433 | 48866 |
|
||||
+---------+--------+--------+
|
||||
<strong>Explanation:</strong>
|
||||
A new column bonus is created by doubling the value in the column salary.</pre>
|
Reference in New Issue
Block a user