Skip to content

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
merged 19 commits into from
Nov 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tweak tests as requested on pr
parametrize tests and use iloc to check value
  • Loading branch information
Nikoleta-v3 committed Nov 11, 2018
commit aa6b4a94e47876062d73d8cd4841845d2fdba4ae
21 changes: 9 additions & 12 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,19 @@ def test_constructor_no_data_index_order(self):
def test_constructor_no_data_string_type(self):
Copy link
Contributor

Choose a reason for hiding this comment

The 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 result.isna().all()
assert np.isnan(result.iloc[0])

Copy link
Contributor

Choose a reason for hiding this comment

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

check the value using iloc instead here which returns a scalar

def test_constructor_single_element_string_type(self):
@pytest.mark.parametrize('item', ['13'])
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to parameterize this test (only 1 case), and you need to change the name as the next test overwrites it.

def test_constructor_single_element_string_type(self, item):
# GH 22477
result = pd.Series(13, index=[1], dtype=str)
assert result.values.tolist() == ['13']
result = pd.Series(int(item), index=[1], dtype=str)
assert result.iloc[0] == item

def test_constructor_string_element_string_type(self):
@pytest.mark.parametrize('item', ['entry', 'ѐ'])
def test_constructor_string_element_string_type(self, item):
# GH 22477
result = pd.Series('entry', index=[1], dtype=str)
assert result.values.tolist() == ['entry']

def test_constructor_unicode_element_string_type(self):
# GH 22477
result = pd.Series('ѐ', index=[1], dtype=str)
assert result.values.tolist() == ['ѐ']
result = pd.Series(item, index=[1], dtype=str)
assert result.iloc[0] == item

def test_constructor_dtype_str_na_values(self, string_dtype):
# https://github.com/pandas-dev/pandas/issues/21083
Expand Down