Skip to content

Commit

Permalink
TST: get_dummies UnicodeEncodeError tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Scorpil committed Jul 30, 2018
1 parent c272c52 commit 5f71404
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pandas/tests/reshape/test_reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,26 @@ def test_dataframe_dummies_with_categorical(self, df, sparse, dtype):
expected.sort_index(axis=1)
assert_frame_equal(result, expected)

def test_dataframe_dummies_unicode(self):
df = pd.DataFrame(({u'ä': ['a']}))
result = get_dummies(df)
expected = pd.DataFrame({u'ä_a': [1]}, dtype=np.uint8)
assert_frame_equal(result, expected)

df = pd.DataFrame({'x': [u'ä']})
result = pd.get_dummies(df)
expected = pd.DataFrame({u'x_ä': [1]}, dtype=np.uint8)
assert_frame_equal(result, expected)

df = pd.DataFrame({'x': ['a']})
result = pd.get_dummies(df, prefix=u'ä')
expected = pd.DataFrame({u'ä_a': [1]}, dtype=np.uint8)
assert_frame_equal(result, expected)

result = pd.get_dummies(df, prefix_sep=u'ä')
expected = pd.DataFrame({u'xäa': [1]}, dtype=np.uint8)
assert_frame_equal(result, expected)

def test_basic_drop_first(self, sparse):
# GH12402 Add a new parameter `drop_first` to avoid collinearity
# Basic case
Expand Down

0 comments on commit 5f71404

Please sign in to comment.