Home > Net >  How to combine columns with multiple parameters into one column line by line?
How to combine columns with multiple parameters into one column line by line?

Time:07-25

for i in range(len('ID')):
    buf = [str(x) for x in LTE_db['robot'][i].split(';')]
    for j in robot_db['robot'][i]:
        try:
            robot_db['final'] = robot_db['ID][i]   '*'   robot_db['Name'][i]   '*'   robot_db['latitude'][i]   '*'   robot_db['longitude'][i]   '*'   buf[j]
        except ValueError:
            pass

1

enter image description here

How to convert data from the first table to the second? You need to do it through Pandas.

CodePudding user response:

df['robot'] = df.data.str.split(', ')
df.explode('robot')

CodePudding user response:

You may use pandas' split method, specifying the comma as your delimiter:

df['robot'].str.split(pat = ',', expand = True)
  • Related