Data Science

Creating and Transforming Columns

Senior Data Analyst
April 20, 2026
5 min read

Simple Calculation

df['total'] = df['price'] * df['quantity']

Apply a Function

df['name_upper'] = df['name'].apply(lambda x: x.upper())

Conditional Column (CASE WHEN)

import numpy as np

df['tier'] = np.where(df['spend'] > 1000, 'Premium', 'Standard')

*Day 111: Reshaping Data (Pivot & Melt).*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.