I have a dataframe
Here i have a column called "name split" which is a column with lists. Now i want to split the contents of the lists and create separate columns for each.
This is what i have tried so far :
df = pd.read_csv("C:/Users/Transorg-PC/Desktop/Training/py/datase/football.csv")
temp = df.copy()
temp['name'] = temp['name'].apply(lambda x: ' '.join(x.split()))
temp['name split'] = temp['name'].apply(lambda x: x.split())
temp['length'] = temp['name split'].str.len()
for i in range(temp['length'].max()-1):
temp[i] = temp['name split'].apply(lambda x:x[i])
But i am not able to iterate like this as for some cases the index goes out of bound. So how to split the contents of the list in separate columns.