I need to splits items in a row to columns on the occurence of '^' character. This needs to done through pandas without a loop preferably
I have
0 A^
3 206-1C
4 502-2B
5 506-0.5C
6 604-1B
7 907-2B
8 G.ELITE^
9 A201-1C
10 A202-1B
I want
| A^ | G.ELITE^ |
|---|---|
| 206-1C | A201-1C. |
| 502-2B. | A202-1B |
| 506-0.5C | |
| 604-1B | |
| 907-2B. |
test=rd.query('texts.str.contains("\^")', engine='python')
One way to do this is to split the dataframe where the value ends in
^and then join those split dataframes horizontally, setting the column names from the splitting values:Assumed sample data:
Output: