I'm trying to add one or more character before a string if a condition (membership sold) has been met. The example:
Huurders verbijsterd over verduistering 596.00... 3 Horeca-echtpaar Bas en Beaudine over verwoeste... 2 Nieuwe coronabesmettingen in Hillegom: ’Wak... 2 Monsters en demonen komen tot leven op dak Koe... 2 Hoofddorp krijgt een stadspark in het centrum,... 2
What I'm trying to achieve is to add an asterix before each string (headliner), corresponding to the amount of sales. I've tried many variations of code including the one below. df['article_title'] = '*' + df['article_title'] if df[df['Transactions'] == 1] else df['article_title']
Quite frankly: I can't seem to execute this quite simple command. Hopefully this community can help me :)
Aucun commentaire:
Enregistrer un commentaire