Dataframe1 has a lot of rows and columns of data. One column is Text. Certain rows in Text column have strings and some strings include within the strings this {ExplodeEList2}
How to explode (expand) those specific rows of Dataframe1 and replace {ExplodeEList2} in each string with each name contained in the separate dataframe EList2['Name']? Thank you! I've been banging my head against my keyboard all day trying to solve this.
Dataframe1:
| Text |
|---|
| Unrelated data |
| Random sample text {ExplodeElist2} and more random sample text. |
| Other unrelated data |
EList2:
| Name |
|---|
| Jack |
| Jon |
| Sally |
How do I generate this in Dataframe1:
| Text |
|---|
| Unrelated data |
| Random sample text Jack and more random sample text. |
| Random sample text Jon and more random sample text. |
| Random sample text Sally and more random sample text. |
| Other unrelated data |
You can use
applyto process all theTextvalues inDataFrame1which contain the stringExplodeElist2, replacing the string with a list of replaced values. You can thenexplodethat list:Output (for your sample data):