Hi,
Thanks for registering with ProjectPro Recipes - get just-in-time learning and release your projects faster with "ready-to-use" Data-Science code snippets.Â
Find below a recipe we launched recently -Â
How to insert a new column based on condition in Python?
Download the code for this recipe and access 1000+ recipes
## How to insert a new column based on condition in Python
def Kickstarter_Example_80():
print()
print(format('How to insert a new column based on condition in Python','*^82'))
import warnings
warnings.filterwarnings("ignore")
# load libraries
import pandas as pd
import numpy as np
# Create an example dataframe
raw_data = {'student_name': ['Miller', 'Jacobson', 'Bali', 'Milner', 'Cooze', 'Jacon', 'Ryaner', 'Sone', 'Sloan', 'Piger', 'Riani', 'Ali'],
'test_score': [76, 88, 84, 67, 53, 96, 64, 91, 77, 73, 52, np.NaN]}
df = pd.DataFrame(raw_data, columns = ['student_name', 'test_score'])
print(); print(df)
# Create a function to assign letter grades
grades = ........
.
.
.
View the complete recipe
Get access to solved, end-to-end projects using such recipes - price increases on March 26
|