-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Astype keeps nan when converting into string #28176
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
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
294dd2e
astype keeps nan when converting into string
makbigc 39b4294
Move the entry to API change section and make it prominent
makbigc b82e02f
Fix entry in v1.0
makbigc 55d1cf7
Move the whatsnew entry to deprecation section
makbigc 99dc246
merge for update
makbigc f44afcf
Add skipna keyword into astype
makbigc b5428c3
Fix linting adn docstring format
makbigc aa62364
merge for update
makbigc d48dc29
fix black format
makbigc b8724e5
Add skipna parameter into DatetimeBlock.astype and Block.astype
makbigc 7f48697
Fix black format
makbigc 9c624c5
resolve mypy issue
makbigc 369c641
Remove kwarg parameter in astype function
makbigc 2754677
Add FutureWarning for string-type conversion
makbigc ce39f6a
Fix black format
makbigc 8e7cd3c
Merge for update
makbigc 35fd58f
Add okwarning to suppress FutureWarning
makbigc 1d29cd0
Add :okwarning: in whatsnew to suppress FutureWarning
makbigc 34c51e0
Add :okwarning: to suppress FutureWarning
makbigc d879778
Add :okwarning: into getting_started/basic.rst
makbigc 9765497
Add :okwarning: into integer_na.rst
makbigc ffed0a0
merge for update
makbigc c0cbe9a
merge for resolving conflict
makbigc 5ff30e0
merge for update
makbigc 3057073
Remove skipna parameter and set skipna=True in astype_nansafe
makbigc 59030b1
Change test_astype_str_map
makbigc 11c2015
fix test_astype_str
makbigc 68c8e85
Fix black format
makbigc 4b80090
merge for update
makbigc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -580,13 +580,13 @@ def test_astype_str(self): | |
tm.assert_frame_equal(result, expected) | ||
|
||
def test_astype_str_float(self): | ||
# see gh-11302 | ||
# GH 25353 | ||
result = DataFrame([np.NaN]).astype(str) | ||
expected = DataFrame(["nan"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback do you recall, was the intent of this test that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC wanted to match numpy |
||
|
||
expected = DataFrame([np.nan], dtype=object) | ||
tm.assert_frame_equal(result, expected) | ||
result = DataFrame([1.12345678901234567890]).astype(str) | ||
|
||
# see gh-11302 | ||
result = DataFrame([1.12345678901234567890]).astype(str) | ||
# < 1.14 truncates | ||
# >= 1.14 preserves the full repr | ||
val = "1.12345678901" if _np_version_under1p14 else "1.1234567890123457" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, @jschendel and I both prefer a deprecation cycle. It looks like you're making a breaking change. Is that correct?