One of the most fundamental things a person trying to learn Pandas in Python must grasp is the differences between apply vs map vs applymap. Although the differences might seem confusing at first, using some real-world examples helps cement the differences.
When data cleaning in Pandas, map() will only function on the rows of a given series
messages['tokenizer'] = messages['tokenizer'].map(lambda x: tokenizer.tokenize(x))
As you can see, I am only changing the values of one series in my data frame, which is why map worked in this instance.
The apply() function is interesting because it can also work exactly the same as above.
messages['tokenizer'] = messages['tokenizer'].apply(lambda x: tokenizer.tokenize(x))
But, it’s not just limited to working on a single series.