Can we perform operations between more than two columns of a dataframe?

Question

In the lesson, we only performed operations between at most two columns of a dataframe. Can we perform operations between more than two columns?

Answer

Yes, you can perform operations between two or more columns. In fact, there is no limit to how many columns you can perform functions on.

For example, say we had a dataframe containing columns for
price, tax, and quantity.

We could perform an operation using all three of these columns:
df['total'] = (df.price + (df.price * df.tax)) * df.quantity

4 Likes

Are you missing a parantheses in the above example?

Hi, I think is not missing. Parantheses close after df.Tax