I have my data -
data = [['abc - a', 'A'], ['def - b', 'B'], ['ghi - c', 'C'], ['jkl - d', 'D']]
df = pd.DataFrame(data, columns = ['names', 'category'])
df
names category
abc - a A
def - b B
ghi - c C
jkl - d D
What I want as my output is -
names division category
abc a A
def b B
ghi c C
jkl d D
There are a lot of methods to perform this, but I want to perform this with this logic -
iterate through each rows of column-names, and store each value in 'st1' and then ->
first, middle, last = st1.partition(' - ')
df['names'] = first
df['division'] = last
and also assigning it to dataframe one by one, please help me to get my desired output in python.