Question: I have a DataFrame with some survey results; each column is the response to a question. However, for a question that allowed multiple (<10) answers from checked boxes, the column has concatenated those answers with the format "Response 1 Checked | Response 4 Checked | Response 6 Checked ....", so I can't just split the column based on a predefined order, as it doesn't say when something was not checked.

```
ID     NormalResponse    MultipleCheckboxResponse
1      Answer3           Response 3
2      Answer1           Response 1| Response 7
3      Answer2           Response 2| Response 4| Response 7
4      Answer2           Response 2 | Response 3

```

How do I split these reasons out as new columns, preferably just with a boolean marker or 1/0 in the cell to determine if it was marked.

I'd like to see

```
ID     NormalResponse    Response1    Response2   Response3     Response4...
1      Answer3           0            0            1            0
2      Answer1           1            0            0            0
3      Answer2           0            1            0            1
4      Answer2           0            1            1            0

```

Answer: 
You can use [`get_dummies`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.get_dummies.html), after some string manipulation to remove the spaces around the vertical bars `|`:

```
>>> resp = df.MultipleCheckboxResponse.str.replace("[\s]*\|[\s]*", "|")
>>> dummies = resp.str.get_dummies(sep="|")
>>> df.iloc[:,:2].join(dummies)
   ID NormalResponse  Response 1  Response 2  Response 3  Response 4  Response 7
0   1        Answer3           0           0           1           0           0
1   2        Answer1           1           0           0           0           1
2   3        Answer2           0           1           0           1           1
3   4        Answer2           0           1           1           0           0

```

Note though that this will only generate columns for the responses which were ever actually seen. If you want a `response6` column even though no one ever reported response6, then you'll need to add those in a loop yourself.
Update: there is at least one answer above that is far better than mine. Don't waste your time with mine.

Pandas Series module has string manipulation functions which may come in handy here. Let's start by trying:

```
from pandas import Series

response_series = df['MultipleCheckboxResponse']
split_responses = response_series.str.split('|')

```

That will split up the concatenated responses. Each element in the returned series will be a list containing each response in that row. From here we can iterate over the length of the series, and the length of each list within the series, placing each individual response in a new column in the original dataframe.

```
for i in range(0, len(split_responses)):
    for j in range(0, len(split_responses.iloc[i]+1):
        df[j+4][i] = split_responses.iloc[i][j]

```