我需要pandas基于特定列中出现的值在数据框中创建新行。
创建Split的模式是有一个半冒号,指示我需要在哪里开始新行。
df
animal cat;dog;cat
animal dog
animal fish
color black;green
color red
wanted_df
animal cat
animal dog
animal cat
animal dog
animal fish
color black
color green
color red
我见过使用pandas split在df中使用给定字符或值创建新列或行的解决方案(例如here:和here:),但是,我还没有见过使用文本值执行此操作的解决方案。我也看到了能够准确地填充pandas中的空值的解决方案(以及我在此处要求的解决方案)。但是,我需要将这两种技术结合起来,对于单行(或两行)的做法是否可行,我尚不清楚。
UYOU
慕村225694
相关分类