Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit ee7ef6e

Browse files
author
Ehsan Totoni
committed
ignore initial nans for series object dtype inference
1 parent 329a34a commit ee7ef6e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

hpat/hiframes/boxing.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,14 @@ def _infer_series_dtype(S):
107107
if S.dtype == np.dtype('O'):
108108
# XXX assuming the whole column is strings if 1st val is string
109109
# TODO: handle NA as 1st value
110-
first_val = S.iloc[0]
110+
i = 0
111+
while i < len(S) and (S.iloc[i] is np.nan or S.iloc[i] is None):
112+
i += 1
113+
if i == len(S):
114+
raise ValueError(
115+
"object dtype infer out of bounds for {}".format(S.name))
116+
117+
first_val = S.iloc[i]
111118
if isinstance(first_val, list):
112119
return _infer_series_list_dtype(S)
113120
elif isinstance(first_val, str):
@@ -118,13 +125,13 @@ def _infer_series_dtype(S):
118125
return datetime_date_type
119126
else:
120127
raise ValueError(
121-
"data type for column {} not supported".format(S.name))
128+
"object dtype infer: data type for column {} not supported".format(S.name))
122129

123130
# regular numpy types
124131
try:
125132
return numpy_support.from_dtype(S.dtype)
126133
except NotImplementedError:
127-
raise ValueError("data type for column {} not supported".format(S.name))
134+
raise ValueError("np dtype infer: data type for column {} not supported".format(S.name))
128135

129136

130137
def _infer_series_list_dtype(S):

0 commit comments

Comments
 (0)