V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
mfanming
V2EX  ›  问与答

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

  •  
  •   mfanming · Oct 13, 2021 · 1119 views
    This topic created in 1657 days ago, the information mentioned may be changed or developed.
    #函数体
    def wordsep(df_word):
    df.loc[df_word.index,['主体']] = '' <------------------这一行
    return result

    #调用
    df['分词'] = df.apply(wordsep,axis=1)
    mfanming
        1
    mfanming  
    OP
       Oct 13, 2021
    函数里怎么也调不出索引值,目前做法是,生成一列跟索引一样的,感觉好笨的方法
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6028 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:22 · PVG 11:22 · LAX 20:22 · JFK 23:22
    ♥ Do have faith in what you're doing.