根据 pandas 中的分隔符复制行的一部分?
是否有可能根据分隔符复制行的一部分
例如,如果我有这样的 df:
Cars Country Trans trans_id
Alto Australia Automatic & Manual auto & man
我想将 & 上的每一行转换为分隔符分为 2 行并保持其他列相同
所需的输出应该是:
Cars Country Trans trans_id New_Trans NewTransID
Alto Australia Automatic & Manual auto & man Automatic auto
Alto Australia Automatic & Manual auto & man Manual man
Is there any possibility to duplicate part of the row based on the delimiter
For example, if I have df like this:
Cars Country Trans trans_id
Alto Australia Automatic & Manual auto & man
I want to convert each row on the & delimiter into 2 rows and keep the other columns same
The desired output should be:
Cars Country Trans trans_id New_Trans NewTransID
Alto Australia Automatic & Manual auto & man Automatic auto
Alto Australia Automatic & Manual auto & man Manual man
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:
Use: