Skip to content

Commit 62fe71e

Browse files
committed
rather insidious issue with taking from a uint64 array with missing values :>
were being promoted to floats
1 parent d1a63cc commit 62fe71e

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
.noseids
2020
.ipynb_checkpoints
2121
.tags
22+
.cache/
2223

2324
# Compiled source #
2425
###################

pandas/tests/frame/test_reshape.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ def verify(df):
629629
names=[None, 'B'])
630630

631631
right = DataFrame(vals, columns=cols, index=idx)
632-
import pdb; pdb.set_trace()
633632
assert_frame_equal(left, right)
634633

635634
# GH4862

pandas/tools/hashing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def hash_tuples(vals, encoding='utf8', hash_key=None):
137137
is_tuple = True
138138
elif not is_list_like(vals):
139139
raise TypeError("must be convertible to a list-of-tuples")
140-
import pdb; pdb.set_trace()
140+
141141
if not isinstance(vals, MultiIndex):
142142
vals = MultiIndex.from_tuples(vals)
143143

pandas/tools/tests/test_hashing.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ def test_categorical_consistency(self):
152152
tm.assert_series_equal(h1, h2)
153153
tm.assert_series_equal(h1, h3)
154154

155+
def test_categorical_with_nan_consistency(self):
156+
c = pd.Categorical.from_codes(
157+
[-1, 0, 1, 2, 3, 4],
158+
categories=pd.date_range('2012-01-01', periods=5, name='B'))
159+
expected = hash_array(c, categorize=False)
160+
c = pd.Categorical.from_codes(
161+
[0],
162+
categories=[pd.Timestamp('2012-01-01')])
163+
result = hash_array(c, categorize=False)
164+
assert result.item() in expected
165+
155166
def test_pandas_errors(self):
156167

157168
for obj in [pd.Timestamp('20130101'), tm.makePanel()]:

pandas/types/cast.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
is_datetime64tz_dtype, is_datetime64_dtype,
1313
is_timedelta64_dtype, is_dtype_equal,
1414
is_float_dtype, is_complex_dtype,
15-
is_integer_dtype, is_datetime_or_timedelta_dtype,
15+
is_integer_dtype, is_unsigned_integer_dtype,
16+
is_datetime_or_timedelta_dtype,
1617
is_bool_dtype, is_scalar,
1718
_string_dtypes,
1819
_coerce_to_dtype,
@@ -265,6 +266,9 @@ def _maybe_promote(dtype, fill_value=np.nan):
265266
elif is_datetimetz(dtype):
266267
if isnull(fill_value):
267268
fill_value = iNaT
269+
elif is_unsigned_integer_dtype(dtype):
270+
if isnull(fill_value):
271+
fill_value = np.iinfo(np.uint64).max
268272
elif is_float(fill_value):
269273
if issubclass(dtype.type, np.bool_):
270274
dtype = np.object_

0 commit comments

Comments
 (0)