0
0
Pandasdata~5 mins

Arithmetic operations on columns in Pandas - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does adding two columns in a pandas DataFrame do?
It adds the values in each row from the two columns and creates a new column with these sums.
Click to reveal answer
beginner
How do you subtract one column from another in pandas?
You use the minus (-) operator between the two columns, like df['col1'] - df['col2'].
Click to reveal answer
beginner
What happens if you multiply a column by a number in pandas?
Each value in the column is multiplied by that number, scaling the entire column.
Click to reveal answer
beginner
How can you create a new column that is the result of dividing one column by another?
Use the division operator (/) between the two columns, like df['col1'] / df['col2'].
Click to reveal answer
beginner
Why is it useful to perform arithmetic operations on DataFrame columns?
It helps to create new insights or features by combining or transforming existing data easily.
Click to reveal answer
What does df['A'] + df['B'] do in pandas?
ACreates a list of columns A and B
BConcatenates columns A and B as strings
CDeletes columns A and B
DAdds values of columns A and B row-wise
How do you multiply all values in column 'X' by 10?
Adf['X'] - 10
Bdf['X'] + 10
Cdf['X'] * 10
Ddf['X'] / 10
Which operator divides one column by another in pandas?
A+
B/
C*
D-
What will df['C'] = df['A'] - df['B'] do?
ACreate column C with row-wise difference of A and B
BAdd columns A and B into C
CMultiply columns A and B into C
DDelete columns A and B
Why perform arithmetic on DataFrame columns?
ATo create new data insights
BTo delete data
CTo rename columns
DTo sort data
Explain how to add two columns in a pandas DataFrame and why you might do this.
Think about combining data from two columns to get a total.
You got /4 concepts.
    Describe how to multiply a DataFrame column by a number and what effect this has on the data.
    Consider how changing each value by a fixed number changes the data.
    You got /4 concepts.