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 string truncation for astype(str) #4437

Merged
merged 1 commit into from
Aug 3, 2013
Merged

BUG: fix string truncation for astype(str) #4437

merged 1 commit into from
Aug 3, 2013

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Aug 2, 2013

closes #4405.

@ghost ghost assigned cpcloud Aug 2, 2013
values = com._astype_nansafe(self.values, dtype)
else:
values = self.values
Copy link
Contributor

Choose a reason for hiding this comment

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

so str hits this here, but should be then changed to object dtype?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep that's right. my mistake. one issue now is that if you pass x.astype(str) and x is not already a string then you'll get back an object array....

should this instead do something like x.map(dtype.type)? that would actually convert to string...but it would pretty slow...i guess object arrays are slow anyway tho

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure, you can certainly take the str in the astype and do it differently if needed (that object)
but make sure its not actually converting to str

I think I do a translation on str,np.string_ in parsers.pyx somewhere (so can pass in a dtype like that)
do the same sort of thing here

@cpcloud
Copy link
Member Author

cpcloud commented Aug 3, 2013

@jreback ok 2 merge?

@jreback
Copy link
Contributor

jreback commented Aug 3, 2013

looks ok

cpcloud added a commit that referenced this pull request Aug 3, 2013
BUG: fix string truncation for astype(str)
@cpcloud cpcloud merged commit aca1a42 into pandas-dev:master Aug 3, 2013
@cpcloud cpcloud deleted the fix-astype-calls branch August 3, 2013 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

string truncation when using Series.astype(str)
2 participants