I have a column where a string of characters represents a monthly series of events.
A str.split method would be ideal but I can't find the right pattern, regex or otherwise, to split on each character.
Col Foo
BBBAAAAAR
into
Col Foo_1 | Col Foo_2 | Col Foo_3 | Col Foo_4 ...
B |B |B |A ...
I currently do it on a loop:
for keys, frames in data_frame_dict.items():
temp1 = frames.Col_Foo.str.split(' ',expand=True).add_prefix('Feat_Mon_')
and then append...
Which works for spaces, but I want every character in a column, which right now has no separation between each element.
But I can't find the method pattern that works for a string of characters either here or in the docs.
EDIT: I have already tried '' as a separator and it returns the right amount of columns, but they're all empty. Its as if its splitting on each character and returning the empty space between characters.
frames.Col Foo.str.split(' ',expand=True).add_prefix('Feat_Mon_')
<----- use ` '' ` in place of ` ' '`''
and it returns the right amount of columns, but they're all empty. Its as if its splitting on each character and returning the empty space between characters.string
just in case but its still not working. I'll investigate that, but this answers the initial question.