October 2019
Beginner to intermediate
674 pages
16h 43m
English
In R and pandas, we can apply arithmetic operations in data columns in a similar manner. Hence, we can perform arithmetic operations such as addition or subtraction on elements in corresponding positions in two or more DataFrames.
Here, we construct a DataFrame in R with columns labeled x and y, and subtract column y from column x:
>norm_df<- data.frame(x=rnorm(7,0,1), y=rnorm(7,0,1))
>norm_df$x - norm_df$y
[1] -1.3870730 2.4681458 -4.6991395 0.2978311 -0.8492245 1.5851009 -1.4620324
The with operator in R also has the same effect as arithmetic operations:
>with(norm_df,x-y)
[1] -1.3870730 2.4681458 -4.6991395 0.2978311 -0.8492245 1.5851009 -1.4620324
In pandas, the same arithmetic operations can be performed ...
Read now
Unlock full access