Create a New Column — LeetCode 2881 Python Solution
EasyPandas
- Problem
- #2881
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
SQL
DataFrame employees +-------------+--------+ | Column Name | Type. | +-------------+--------+ | name | object | | salary | int.Example
SQL
DataFrame employees
+-------------+--------+
| Column Name | Type. |
+-------------+--------+
| name | object |
| salary | int. |
+-------------+--------+Python solution
Python
import pandas as pd
def createBonusColumn(employees: pd.DataFrame) -> pd.DataFrame:
employees['bonus'] = employees['salary'] * 2
return employeesComplexity
| Measure | Complexity |
|---|---|
| Time | O(1) |
| Space | O(1) auxiliary |
Related problems
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.