-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix (22477) dtype=str converts NaN to 'n' #22564
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
Merged
jorisvandenbossche
merged 19 commits into
pandas-dev:master
from
Nikoleta-v3:fix_issue_22477
Nov 20, 2018
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f069fc2
tests for creating series string dtype
Nikoleta-v3 062786f
Closes #22477
Nikoleta-v3 a522d7f
undo changes to series.py
Nikoleta-v3 c8667dd
comment issue number under test
Nikoleta-v3 4717e36
add test for strings
Nikoleta-v3 bdad724
add test for unicode elements: fails
Nikoleta-v3 7691c82
except unicode in is_datetime64_dtype
Nikoleta-v3 00a7ed8
series with dtype accept unicode
Nikoleta-v3 e9a290d
fixes failure with python2
Nikoleta-v3 aa6b4a9
tweak tests as requested on pr
Nikoleta-v3 ee854d7
style tweak
Nikoleta-v3 64f6e1c
Merge branch 'master' into PR_TOOL_MERGE_PR_22564
jreback fdad0c5
fixup
jreback 31021b6
Merge branch 'master' into PR_TOOL_MERGE_PR_22564
jreback 9711d35
fix test
jreback 086d2b5
Merge branch 'master' into PR_TOOL_MERGE_PR_22564
jreback 27701e0
fixup
jreback 265f92d
Merge branch 'master' into PR_TOOL_MERGE_PR_22564
jreback 0692db0
fixup
jreback 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,17 @@ def test_constructor_no_data_index_order(self): | |
result = pd.Series(index=['b', 'a', 'c']) | ||
assert result.index.tolist() == ['b', 'a', 'c'] | ||
|
||
def test_constructor_no_data_string_type(self): | ||
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. pls parametrize these tests |
||
# GH 22477 | ||
result = pd.Series(index=[1], dtype=str) | ||
assert np.isnan(result.iloc[0]) | ||
|
||
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. check the value using iloc instead here which returns a scalar |
||
@pytest.mark.parametrize('item', ['entry', 'ѐ', 13]) | ||
def test_constructor_string_element_string_type(self, item): | ||
# GH 22477 | ||
result = pd.Series(item, index=[1], dtype=str) | ||
assert result.iloc[0] == str(item) | ||
|
||
def test_constructor_dtype_str_na_values(self, string_dtype): | ||
# https://github.com/pandas-dev/pandas/issues/21083 | ||
ser = Series(['x', None], dtype=string_dtype) | ||
|
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.
prefer to have all of the dtype checking in the if/elif/else and then construct the subarr after
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.
In that case,
dtype
needs to be overwritten withobject
because we don't want actual string dtypes (which is easy to do, just noting :-))