Skip to content

Commit 3954f5d

Browse files
committed
Avoid .base
1 parent c868449 commit 3954f5d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pandas/_libs/tslibs/conversion.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
877877
for i in range(n):
878878
v = vals[i]
879879
result[i] = _tz_convert_tzlocal_utc(v, tz, to_utc=True)
880-
return result.base # `.base` to access underlying np.array
880+
return np.asarray(result)
881881

882882
if is_string_object(ambiguous):
883883
if ambiguous == 'infer':
@@ -1031,7 +1031,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
10311031
stamp = _render_tstamp(val)
10321032
raise pytz.NonExistentTimeError(stamp)
10331033

1034-
return result.base # `.base` to access underlying np.array
1034+
return np.asarray(result)
10351035

10361036

10371037
cdef inline bisect_right_i8(int64_t *data, int64_t val, Py_ssize_t n):
@@ -1133,7 +1133,7 @@ def normalize_i8_timestamps(int64_t[:] stamps, object tz=None):
11331133
dt64_to_dtstruct(stamps[i], &dts)
11341134
result[i] = _normalized_stamp(&dts)
11351135

1136-
return result.base # .base to access underlying np.ndarray
1136+
return np.asarray(result)
11371137

11381138

11391139
@cython.wraparound(False)

pandas/_libs/tslibs/fields.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def get_date_name_field(int64_t[:] dtindex, object field, object locale=None):
132132
else:
133133
raise ValueError("Field {field} not supported".format(field=field))
134134

135-
return out.base # `.base` to access underlying np.array
135+
return np.asarray(out)
136136

137137

138138
@cython.wraparound(False)
@@ -376,7 +376,7 @@ def get_start_end_field(int64_t[:] dtindex, object field,
376376
else:
377377
raise ValueError("Field {field} not supported".format(field=field))
378378

379-
return out.base.view(bool) # `.base` to access underlying np.array
379+
return np.asarray(out).view(bool)
380380

381381

382382
@cython.wraparound(False)
@@ -529,9 +529,9 @@ def get_date_field(int64_t[:] dtindex, object field):
529529
return isleapyear_arr(get_date_field(dtindex, 'Y'))
530530

531531
else:
532-
raise ValueError("Field %s not supported" % field)
532+
raise ValueError("Field {field} not supported".format(field=field))
533533

534-
return out.base # `.base` to access underlying np.array
534+
return np.asarray(out)
535535

536536

537537
@cython.wraparound(False)
@@ -642,7 +642,7 @@ def get_timedelta_field(int64_t[:] tdindex, object field):
642642
else:
643643
raise ValueError("Field {field} not supported".format(field=field))
644644

645-
return out.base # `.base` to access underlying np.array
645+
return np.asarray(out)
646646

647647

648648
cpdef isleapyear_arr(ndarray years):

0 commit comments

Comments
 (0)