我有一個熊貓的數據幀,看起來像這樣的列(長得多,但這裏的前幾名行):回合大熊貓數據幀/系列
>df_fill['col1']
0 5987.8866699999998672865
1 52215.5966699999989941716
2 201.8966700000000003001
3 3.8199999999999998401
我想整列四捨五入到5位小數地方。我可以將它舍入到整數,但不是小數點後的數字。該列的類型是浮動的。
> np.around(df_fill['col1'], 0)
0 5988
1 52216
2 202
3 4
> np.around(df_fill['col1'], 5)
0 5987.8866699999998672865
1 52215.5966699999989941716
2 201.8966700000000003001
3 3.8199999999999998401
> (df_fill['col1']).round()
0 5988
1 52216
2 202
3 4
>(df_fill['col1']).round(5)
0 5987.8866699999998672865
1 52215.5966699999989941716
2 201.8966700000000003001
3 3.8199999999999998401
> (df_fill['col1']).round(decimals=5)
0 5987.8866699999998672865
1 52215.5966699999989941716
2 201.8966700000000003001
3 3.8199999999999998401
> str((df_fill['col1']).round(decimals=5))
'0 5987.8866699999998672865\n1 52215.5966699999989941716\n2 201.8966700000000003001\n3 3.8199999999999998401\
我在這裏錯過了什麼?
不會'df_fill [ 'COL1']。輪(5)'只是工作? – EdChum
什麼是'df_fill ['col1']。dtype'? – unutbu
@EdChum沒有工作,試圖在小數點後仍然得到19位數的結果。 – lilyrobin