V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
lemeet
V2EX  ›  问与答

Python 怎么把上面的 df 变成下面的 df,麻烦大佬帮忙解答一下, Python 新手,谢谢

  •  
  •   lemeet · 2018-11-11 13:53:06 +08:00 · 937 次点击
    这是一个创建于 2001 天前的主题,其中的信息可能已经有所发展或是发生改变。

    user_id r_score f_score m_score
    0 1 5 1 1 1 2 2 1 1 2 5 4 1 1 3 7 2 1 1 4 9 2 1 1

    user_id r_score f_score m_score r_height r_height f_height m_height 0 1 5 1 1 高 低 低 1 2 2 1 1 高 低 低 2 5 4 1 1 高 低 低 3 7 2 1 1 低 低 低 4 9 2 1 1 低 低 低

    1 条回复    2018-11-11 18:03:44 +08:00
    Yvette
        1
    Yvette  
       2018-11-11 18:03:44 +08:00 via iPad
    import pandas as pd
    pf = pd.DataFrame([[1, 2], [5, 3]])
    pf["height"] = pf.iloc[:, 0] > pd.iloc[:, 1]
    print(pf)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1148 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:55 · PVG 01:55 · LAX 10:55 · JFK 13:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.