Rounding in numpy?

前端 未结 2 383
野趣味
野趣味 2021-01-19 10:23

I have strange problem with python pandas and numpy.

>>> np.float64(1) * np.float64(85000) * np.float64(7.543709)
641215.26500000001

>>> r         


        
2条回答
  •  离开以前
    2021-01-19 11:00

    Yes, but you can't use round( float(num), 2 ) when you work with dataframes:

    for examle: df.first * df.second * df.third How to round in that case? You can't make float(dt.first)?

    This is one solution: df.first.apply(lambda x: round(float(x), 2)) But I think is not fast...

提交回复
热议问题