np.where Not Working in my Pandas

后端 未结 1 1970
别跟我提以往
别跟我提以往 2020-12-19 03:36

I have an np.where problem using Pandas that is driving me crazy and I can\'t seem to solve through Google, the documentation, etc.

I\'m hoping someone has insight.

相关标签:
1条回答
  • 2020-12-19 04:06

    You need to pass the boolean mask and the (two) values columns:

    np.where(Full_Names_Test_2['MarketCap'] == 'n/a', 7)
    # should be
    np.where(Full_Names_Test_2['MarketCap'] == 'n/a', Full_Names_Test_2['MarketCap'], 7)
    

    See the np.where docs.

    or alternatively use the where Series method:

    Full_Names_Test_2['MarketCap'].where(Full_Names_Test_2['MarketCap'] == 'n/a', 7)
    
    0 讨论(0)
提交回复
热议问题