小编Fel*_*ang的帖子

如何遍历 Pandas DataFrame 并将字符串拆分为多行

循环遍历带有字符串的数据帧的最佳方法是什么,我想将其拆分为多行同时保留另一个值?

输入:

genres                   revenue
action|comedy|drama       5000
action|romance            10000
Run Code Online (Sandbox Code Playgroud)

输出:

genres      revenue
action      5000
comedy      5000
drama       5000
action      10000
romance     10000
Run Code Online (Sandbox Code Playgroud)

python dataframe python-3.x pandas

3
推荐指数
1
解决办法
106
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1

python-3.x ×1