Skip to content

BUG: conversion of float32 to string shows too much precision #36451

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

On master (but also on 1.1):

In [4]: pd.Series([0.1], dtype="float64").astype("string")
Out[4]: 
0    0.1
dtype: string

In [5]: pd.Series([0.1], dtype="float32").astype("string")
Out[5]: 
0    0.10000000149011612
dtype: string

When converting to the object-dtype string, it works as expected:

In [6]: pd.Series([0.1], dtype="float64").astype("str")
Out[6]: 
0    0.1
dtype: object

In [7]: pd.Series([0.1], dtype="float32").astype("str")
Out[7]: 
0    0.1
dtype: object

cc @topper-123

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugRegressionFunctionality that used to work in a prior pandas versionStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions