Modification

Add column

df['colName'] = [1,2,4,5]
# sets all respectively

df['colName'] = 0
# sets all to 0

df['colName'] = df.colName1 + df.colName2
# sets based on other col values in respective row

Lambda Functions

funcName = lambda parameterName: parameterName * 2

lambda x: [OUTCOME IF TRUE] if [CONDITIONAL] else [OUTCOME IF FALSE]
myfunction = lambda x: 40 + (x - 40) * 1.50 if x > 40 else x

Column Operations

df['colName'] = df['colName'].apply(upper)
# sets all strings to upper case, works with  lower  aswell

df['colName'] = df['colName'].apply(lambda x: x + 2)
# adds 2 to colName, x takes value of colName

df['colName'] = df['colName'].apply(lambdaFuncName)
# note there is no ()

Row Operations

df['rowName'] = df.apply(func, axis=1)
# to apply to a row we must set axis to 1

Renaming Columns

df.columns = ['firstCol', 'secondCol', 'finalCol']
# must list out all columns in the correct order

df.rename(columns = {
	'oldColName': 'newColName',
	'oldColName1': 'newColName1'},
	inplace = True)