如何将一列分成2个? [英] How can I split a column into 2?

查看:95
本文介绍了如何将一列分成2个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下df:

                    0
0    Fuerte venta (0,00)*
1   Infraponderar (0,00)*
2        Neutral (14,00)*
3   Sobreponderar (2,00)*
4  Fuerte compra (11,00)*

如何将列分为两列以获得以下输出:

How could I split the column into 2 columns in order to obtain the following output:

           0         1
0    Fuerte venta (0,00)*
1   Infraponderar (0,00)*
2        Neutral (14,00)*
3   Sobreponderar (2,00)*
4  Fuerte compra (11,00)*

推荐答案

您可以使用str.rsplit

You can use str.rsplit

pd.DataFrame(df['0'].str.rsplit(' ', 1).tolist())

你得到

    0               1
0   Fuerte venta    (0,00)*
1   Infraponderar   (0,00)*
2   Neutral         (14,00)*
3   Sobreponderar   (2,00)*
4   Fuerte compra   (11,00)*

这篇关于如何将一列分成2个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆