I am trying to delimit/parse phrases within the cells of a column based on white space. I am using the Panda Module in Python 3.4. So an example of what I am trying to do would turn this:
Keyword Number Row
Bob Jim Jon 300 2
Into this:
Keyword Number Row
Bob 300 2
Jim 300 2
Jon 300 2
I've been researching how to do this throughout the forums and stumbled upon this question which is very similar (and which won't let me comment on it directly to ask this question): pandas: How do I split text in a column into multiple rows?
Adapting the answer from that post I have created this code:
import pandas as pd
xl = pd.ExcelFile("C:/Users/j/Desktop/helloworld.xlsx")
df = xl.parse("HelloWorld")
df.head()
df1 = df[['Keyword','Number','Row']]
s = df1['Keyword'].str.split(' ').apply(Series, 1).stack()
s.index = s.index.droplevel(-1)
s.name = 'Keyword'
del df1['Keyword']
y = df1.join(s)
print(y)
However, when I try this I get the following error
s = df['Keyword'].str.split(' ').apply(Series, 1).stack()
NameError: name 'Series' is not defined
Any suggestions as to what I am doing wrong? Thank you!