I have a function and a for loop I am using to split a column into 5 around '.'. This was working on the first run but now it is spitting out a value error of : Wrong number of items passed 2, placement implies 1.
The specific line it has an issue with is:
----> 6 data["Keyword"+str(i+1)] = remove_id(i)
I am a little stumped. As far as I can tell the code is creating a new column called Keyword1,2,3,4,5 and adding in the data form each split.
new = data["keywords"].str.split(",", n = 6,expand = True)
def remove_id(i):
return new[i].str.split(".", n=1, expand = True)
for i in range(5):
data["Keyword"+str(i+1)] = remove_id(i)
data.head()
Any help would be greatly appreciated.
Thanks
Here is the 'new' data frame created to house the keywords after they are split: