Issue
My code is -
df=pd.read_csv("file path")
l1=[]
l2=[]
for i in range(0,len(df['unions']),len(df['district'])):
l1.append((df['unions'][i], df['district'][i]))
l2.append(({"entities": [(0,len(df['unions'][i]),df['subdistrict'][i])]}))
TRAIN_DATA=list(zip(l1,l2))
print(TRAIN_DATA)
Result I got - [(('Dhansagar', 'Bagerhat'), {'entities': [(0, 9, 'Sarankhola')]})]
But I want to get result is this format -
[(('Dhansagar Bagerhat'), {'entities': [(0, 9, 'Sarankhola')]})]
Basically no comma in between Dhansagar Bagerhat. How do I do it? Also, why am I getting only one result? It seems like my loop is not working.
Solution
Instead of:
l1.append((df['unions'][i], df['district'][i]))
Try:
l1.append(' '.join((df['unions'][i], df['district'][i])))
Or:
l1.append((df['unions'][i] + " " + df['district'][i]))
Answered By - U12-Forward Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.