I'm relatively new to Python and would like to seek your help in the following problem. My current series of information looks like this:
df['word_feats']
------------------------------------------------
0 Case=Loc|Gender=Neut|Number=Sing|Person=3
1 Case=Nom|Gender=Neut|Number=Sing|Person=3
2 PunctType=Comm
3 Case=Nom|Gender=Neut|Number=Sing|Person=3
4 Case=Nom|Gender=Neut|Number=Sing|Person=3
5 None
6 Case=Nom|Gender=Neut|Number=Sing|Person=3
7 Case=Loc|Gender=Neut|Number=Sing|Person=3
8 Gender=Neut|Number=Sing|Person=3
9 Case=Loc|Gender=Neut|Number=Plur|Person=3
10 None
My results in a single column are not in a dictionary format (which would be easier). Instead, it is in a pipe separated format with equals sign.
I am hoping to split this series into multiple columns, taking the 'key' (in this case, LEFT of equal sign) as the column name, and 'value' (RIGHT of equal sign) as my cell.
I've tried something along this line:
df['word_feats'].str.split('|', expand=True)
Which doesn't work as:
- It doesn't take the 'key' as column name
- My values are in the wrong columns!
Would appreciate any answers for this! Thanks.