如何拆分和扩展系列列表

时间:2018-11-27 09:47:16

标签: python pandas

我的原始数据帧如下所示,ItemId包含ItemID的列表:

Index   ItemID
538935  [5H9241070, 5I9242410]
538936  [5I9320910, 5I9710520]
538937  [7I9400230, 7I9400230]
538938  [5I0280220]
538939  [9I9230350, 9I9310960]
538940  [9I0311260, 9I8230470, 9I823280T]
538941  [9I7310860]
538942  [9I9322220]
538943  [9I8200560]
538944  [5I0820050]
538945  [5I0820340, 5I0310420]
538946  [5I9820040]

请如何像上面的数据框一样转换上面的数据框?

Index   ItemID_1  ItemID_2   ItemID_3....
538935  5H9241070  5I9242410  np.nan
538936  5I9320910  5I9710520  np.nan
538937  7I9400230  7I9400230  np.nan
538938  5I0280220  np.nan   np.nan
538939  9I9230350 9I9310960 np.nan
538940  9I0311260 9I8230470 9I823280T
538941  9I7310860  np.nan   np.nan
538942  9I9322220  np.nan  np.nan
538943  9I8200560 np.nan  np.nan
538944  5I0820050  np.nan  np.nan
538945  5I0820340 5I0310420  np.nan
538946  5I9820040  np.nan  np.nan

0 个答案:

没有答案