Skip to content

Commit f069fc2

Browse files
committed
tests for creating series string dtype
More specifically the cases that seem to have an issue are when: - the series in empty - it's a single element series
1 parent 58a59bd commit f069fc2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/series/test_constructors.py

+8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ def test_constructor_no_data_index_order(self):
134134
result = pd.Series(index=['b', 'a', 'c'])
135135
assert result.index.tolist() == ['b', 'a', 'c']
136136

137+
def test_constructor_no_data_string_type(self):
138+
result = pd.Series(index=[1], dtype=str)
139+
assert result.isna().all()
140+
141+
def test_constructor_single_element_string_type(self):
142+
result = pd.Series(13, index=[1], dtype=str)
143+
assert result.values.tolist() == ['13']
144+
137145
def test_constructor_dtype_str_na_values(self, string_dtype):
138146
# https://github.com/pandas-dev/pandas/issues/21083
139147
ser = Series(['x', None], dtype=string_dtype)

0 commit comments

Comments
 (0)