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

pandas 怎么在函数里,调用当前行索引值?

  •  
  •   mfanming · 2021-10-13 11:37:25 +08:00 · 418 次点击
    这是一个创建于 928 天前的主题,其中的信息可能已经有所发展或是发生改变。
    #函数体
    def wordsep(df_word):
    df.loc[df_word.index,['主体']] = '' <------------------这一行
    return result

    #调用
    df['分词'] = df.apply(wordsep,axis=1)
    mfanming
        1
    mfanming  
    OP
       2021-10-13 11:42:07 +08:00
    函数里怎么也调不出索引值,目前做法是,生成一列跟索引一样的,感觉好笨的方法
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3390 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 10:58 · PVG 18:58 · LAX 03:58 · JFK 06:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.