Skip to content

Commit bfe6322

Browse files
committed
Add file
1 parent 8e119ed commit bfe6322

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Diff for: introduction-pandas/2884-modify-columns.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
2884. Modify Columns
3+
Solved
4+
Easy
5+
Companies
6+
Hint
7+
DataFrame employees
8+
+-------------+--------+
9+
| Column Name | Type |
10+
+-------------+--------+
11+
| name | object |
12+
| salary | int |
13+
+-------------+--------+
14+
A company intends to give its employees a pay rise.
15+
16+
Write a solution to modify the salary column by multiplying each salary by 2.
17+
18+
The result format is in the following example.
19+
20+
Example 1:
21+
22+
Input:
23+
DataFrame employees
24+
+---------+--------+
25+
| name | salary |
26+
+---------+--------+
27+
| Jack | 19666 |
28+
| Piper | 74754 |
29+
| Mia | 62509 |
30+
| Ulysses | 54866 |
31+
+---------+--------+
32+
Output:
33+
+---------+--------+
34+
| name | salary |
35+
+---------+--------+
36+
| Jack | 39332 |
37+
| Piper | 149508 |
38+
| Mia | 125018 |
39+
| Ulysses | 109732 |
40+
+---------+--------+
41+
Explanation:
42+
Every salary has been doubled."
43+
"""
44+
45+
import pandas as pd
46+
47+
def modifySalaryColumn(employees: pd.DataFrame) -> pd.DataFrame:
48+
employees['salary'] = employees['salary'] * 2
49+
return employees

0 commit comments

Comments
 (0)