Working of map vs applymap in pandas, python
Yes, apply works on a row or a column basis of a DataFrame, applymap works element-wise on a DataFrame.
I am newbie to data science and I am bit confused about working of map and applymap in pandas. As when I executed code df.applymap(lambda f: f*2) and df.apply(lambda f: f*2) provided same result. But when I change code for both which were df.applymap(lambda f: f*2 if f < 7 else f) and df.apply(lambda f: f*2 if f < 7 else f) then apply method caused an error. Upon my understanding, I came to conclusion that applymap works for each scalar value where apply does not work for each scalar value but instead it executes operation for whole column or series.
Kindly veterans help me out here if I am correct or not. Thanks in advance
Note: df in code refers to whole DataFrame not series.