EasyNo. 2881
Create a New Column — LeetCode 2881 Python Solution
- Topics
- Pandas
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
DataFrame employees +-------------+--------+ | Column Name | Type. | +-------------+--------+ | name | object | | salary | int.Example
DataFrame employees
+-------------+--------+
| Column Name | Type. |
+-------------+--------+
| name | object |
| salary | int. |
+-------------+--------+Python solution
import pandas as pd
def createBonusColumn(employees: pd.DataFrame) -> pd.DataFrame:
employees['bonus'] = employees['salary'] * 2
return employeesComplexity
- Time
- O(1)
- Space · auxiliary
- O(1)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 2877 | Create a DataFrame from List | Easy |
| 2874 | Maximum Value of an Ordered Triplet II | Medium |
| 2873 | Maximum Value of an Ordered Triplet I | Easy |
| 0057 | Insert Interval | Medium |
| 0192 | Word Frequency | Medium |
| 0193 | Valid Phone Numbers | Easy |
Frequently asked questions
- How hard is LeetCode 2881. Create a New Column?
LeetCode 2881. Create a New Column is rated Easy on LeetCode.
- What is the time complexity of LeetCode 2881. Create a New Column?
The Python solution on this page runs in O(1).
- What is the space complexity of LeetCode 2881. Create a New Column?
The Python solution on this page uses O(1) auxiliary space.
- What topics does LeetCode 2881. Create a New Column cover?
LeetCode 2881. Create a New Column is tagged Pandas on LeetCode.