Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix astype from float32 to string #36464

Merged
merged 6 commits into from
Sep 21, 2020
Merged

BUG: Fix astype from float32 to string #36464

merged 6 commits into from
Sep 21, 2020

Conversation

dsaxton
Copy link
Member

@dsaxton dsaxton commented Sep 19, 2020

It seems both bugs were caused by the same behavior from numpy:

[ins] In [1]: import numpy as np

[ins] In [2]: arr = np.array([0.1], dtype=np.float32)

[ins] In [3]: arr
Out[3]: array([0.1], dtype=float32)

[ins] In [4]: np.asarray(arr, dtype="object")
Out[4]: array([0.10000000149011612], dtype=object)

@dsaxton dsaxton added Bug Regression Functionality that used to work in a prior pandas version Strings String extension data type and string data labels Sep 19, 2020
@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Sep 19, 2020
@jreback jreback added this to the 1.1.3 milestone Sep 19, 2020
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch and quick fix!

(so it's actually not numpy, but stdlib float that has the different behaviour)

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you can update the whatsnew

doc/source/whatsnew/v1.1.3.rst Show resolved Hide resolved
@jorisvandenbossche jorisvandenbossche merged commit a0d6d06 into pandas-dev:master Sep 21, 2020
@jorisvandenbossche
Copy link
Member

Thanks @dsaxton !

@jorisvandenbossche
Copy link
Member

@meeseeksdev backport to 1.1.x

@lumberbot-app
Copy link

lumberbot-app bot commented Sep 21, 2020

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout 1.1.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 a0d6d061de42c54b8071d28a4bf60cd69853c388
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #36464: BUG: Fix astype from float32 to string'
  1. Push to a named branch :
git push YOURFORK 1.1.x:auto-backport-of-pr-36464-on-1.1.x
  1. Create a PR against branch 1.1.x, I would have named this PR:

"Backport PR #36464 on branch 1.1.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Sep 21, 2020
simonjayhawkins pushed a commit that referenced this pull request Sep 21, 2020
Co-authored-by: Daniel Saxton <2658661+dsaxton@users.noreply.github.com>
@dsaxton dsaxton deleted the float32-to-str-precision branch September 21, 2020 12:18
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Regression Functionality that used to work in a prior pandas version Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: conversion of float32 to string shows too much precision
3 participants