June 2018
Beginner
508 pages
13h 8m
English
Now it's time to increase the complexity. First of all, we want to get rid of that horrible campaign name (cmp_name). We need to explode it into parts and put each part in one dedicated column. In order to do this, we'll use the apply method of the Series object.
The pandas.core.series.Series class is basically a powerful wrapper around an array (think of it as a list with augmented capabilities). We can extrapolate a Series object from DataFrame by accessing it in the same way we do with a key in a dictionary, and we can call apply on that Series object, which will run a function feeding each item in the Series to it. We compose the result into a new DataFrame, and then join that DataFrame with df:
#8def unpack_campaign_name(name): ...
Read now
Unlock full access