EasyNo. 2884
Modify Columns — LeetCode 2884 Python Solution
- Topics
- Pandas
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
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.Example
DataFrame employees
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| salary | int |
+-------------+--------+Python solution
import pandas as pd
def modifySalaryColumn(employees: pd.DataFrame) -> pd.DataFrame:
employees['salary'] *= 2
return employeesComplexity
- Time
- O(n)
- Space · auxiliary
- O(1) to O(n)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 2877 | Create a DataFrame from List | Easy |
| 2874 | Maximum Value of an Ordered Triplet II | Medium |
| 0057 | Insert Interval | Medium |
| 0192 | Word Frequency | Medium |
| 0193 | Valid Phone Numbers | Easy |
| 0194 | Transpose File | Medium |
Frequently asked questions
- How hard is LeetCode 2884. Modify Columns?
LeetCode 2884. Modify Columns is rated Easy on LeetCode.
- What topics does LeetCode 2884. Modify Columns cover?
LeetCode 2884. Modify Columns is tagged Pandas on LeetCode.