mirror of https://github.com/doocs/leetcode.git
|
…
|
||
|---|---|---|
| .. | ||
| README.md | ||
| README_EN.md | ||
| Solution.py | ||
README_EN.md
| comments | difficulty | edit_url | tags | |
|---|---|---|---|---|
| true | Easy | https://github.com/doocs/leetcode/edit/main/solution/2800-2899/2884.Modify%20Columns/README_EN.md |
|
2884. Modify Columns
Description
DataFrame employees
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| salary | int |
+-------------+--------+
A company intends to give its employees a pay rise.
Write a solution to modify the salary column by multiplying each salary by 2.
The result format is in the following example.
Example 1:
Input: DataFrame employees +---------+--------+ | name | salary | +---------+--------+ | Jack | 19666 | | Piper | 74754 | | Mia | 62509 | | Ulysses | 54866 | +---------+--------+ Output: +---------+--------+ | name | salary | +---------+--------+ | Jack | 39332 | | Piper | 149508 | | Mia | 125018 | | Ulysses | 109732 | +---------+--------+ Explanation: Every salary has been doubled.
Solutions
Solution 1
Python3
import pandas as pd
def modifySalaryColumn(employees: pd.DataFrame) -> pd.DataFrame:
employees['salary'] *= 2
return employees