为什么我不能像 python 中的整数那样按浮点数过滤列?



例如:

df[df['nums']==23].head() #gives what its supposed to, but 
df[df['nums']==35.0454545455].head() #gives a blank df and that value exists in the column.

浮点值比您提供的筛选器更具体。

您可以四舍五入您的浮点值并进行比较,或者>=某个值会起作用。除非精确到最后一个小数点,否则精确的浮点是不起作用的。

最新更新