Use DataFrame.explode
(pandas 0.25+) with Series.str.strip
and Series.str.split
column Tags
for lists:
df1 = (df.assign(Tags = df['Tags'].str.strip('><').str.split('><'))
.explode('Tags')
.reset_index(drop=True))
You have to split and then explode your dataframe.
df['Tags'] = df['Tags'].astype('str')
for i in range(len(df)):
df.at[i, 'Tags'] = df[i, df['Tags'].strip('><').split('><')]
df.explode('Tags')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.