Python pandas dataframe split lines (some lines are split into multiple lines)

for example, there is data

A B C
1 1 br 2 3
2 3 3
3 4 record5 1 3

such a table should be divided into
A B C
1 13
1 23
2 3
3 43
1 53
1 63
excuse me how to operate

Mar.29,2021

< H2 > simple loop < / H2 >

the easiest way is to break it up in a loop. The easiest way to go first:

df = pd.DataFrame({'A':['1','2','3'],'B':['1','2,3','4,5,6'],'C':['3','3','3']})
df = (df.set_index(['A','C'])['B']
       .str.split(',', expand=True)
       .stack()
       .reset_index(level=2, drop=True)
       .reset_index(name='B'))
print(df)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43c51-4371a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43c51-4371a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?