Community request time! Thanks to Leonah for the tutorial request about how to multiply columns in pandas

Multiplying columns together is a foundational skill in Pandas and a great one to master. Good thing it is straightforward and easy to pick up.
1. df['your_new_column'] = df['col1'] * df['col2']
In the video below we’ll review two methods for multiplying columns together and saving the result on your dataframe.
Code from the video. Looks like the formatting of many columns is very off. To view a nice version, head over to the git hub link below.
Mulitplying columns together to make a 3rd column¶
Goal: Multiply columns
import pandas as pd
df = pd.read_csv('../data/Street_Tree_List.csv')
df.head(2)
Method 1: Multiply Series together¶
df['multiplied_column'] = df['TreeID'] * df['SiteOrder']
Method 2: Iterate through column and multiply¶
results_list = []
for i, row in df.iterrows():
result = (row['TreeID']/2) * row['SiteOrder']
results_list.append(result)
df['multiplied_column2'] = results_list
df.head(3)
Check out more Pandas functions on our Pandas Page