Skip to content
Advertisement

Dataframe new columns to tell if the row contains column’s header text

2 columns dataframe as the first screenshot. I want to add new columns (by the contents in the Note column from the original dataframe) to tell if the Note column contains the new column’s header text.

Example as the second screenshot.

enter image description here

Some lines work for a few columns. When there are a lot of new columns, it’s not efficient.

What is a good way to do so?

JavaScript

Advertisement

Answer

You can try .str.get_dummies then replace 1 with Yes

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement