Looking to split text into columns based on the text found in parentheses and allocate based on the string matches within the column.
The raw content is in the format of:
| Text |
|---|
| (nytimes) "news on war" (wsj) "news on business" (nytimes) "more news" |
Looking for it to produce the output of:
| Text | NYTimes | WSJ |
|---|---|---|
| (nytimes) "news on war with the nytimes" (wsj) "news on business" (nytimes) "more news on ware" | ["news on war with the nytimes", "more news"] | ["news on business"] |
All of the strings within parentheses are known. I started with this code but an unsure how to proceed. Cannot simply delimit by the news organization, but on the parentheses.
df['nytimes'] = df['text'].apply(lambda text: [group for group in text.split(regex)])