Informatics Practices
Is the result of sub() and rsub() the same? Why/why not ?
Python Pandas
2 Likes
Answer
The sub() and rsub() functions produce different results because they subtract the operands in a different order. The sub() function performs element-wise subtraction between two DataFrames, subtracting the right operand from the left operand. The syntax is <DF1>.sub(<DF2>), which means <DF1> - <DF2>. On the other hand, the rsub() function performs element-wise subtraction with the right operand subtracted from the left operand. The syntax is <DF1>.rsub(<DF2>), which means <DF2> - <DF1>.
Answered By
1 Like
Related Questions
Name the function to iterate over a DataFrame vertically.
Write equivalent expressions for the given functions :
(i) A.add(B)
(ii) B.add(A)
(iii) A.sub(B)
(iv) B.sub(A)
(v) A.rsub(B)
(vi) B.mul(A)
(vii) A.rdiv(B)
(viii) B.div(A)
(ix) B.rdiv(A)
(x) A.div(B)
Write appropriate functions to perform the following on a DataFrame ?
(i) Calculate the sum
(ii) Count the values
(iii) Calculate the average
(iv) Calculate the most repeated value
(v) Calculate the median
(vi) Calculate the standard deviation
(vii) Calculate the variance
(viii) Calculate the maximum value
(ix) Calculate the standard deviation
(x) Calculate the variance
What does info() and describe() do ?