Skip to content

Commit 917d749

Browse files
committed
use cimports
1 parent 729b237 commit 917d749

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pandas/_libs/reshape.pyx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ from cython import Py_ssize_t
33

44
from numpy cimport (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
55
uint32_t, uint64_t, float32_t, float64_t, ndarray)
6-
import numpy
6+
cimport numpy as cnp
7+
import numpy as np
78
from pandas._libs.lib cimport c_is_list_like
8-
9+
cnp.import_array()
910

1011
ctypedef fused reshape_t:
1112
uint8_t
@@ -118,7 +119,7 @@ def explode(ndarray[object] values):
118119

119120
# find the resulting len
120121
n = len(values)
121-
counts = numpy.zeros(n, dtype='int64')
122+
counts = np.zeros(n, dtype='int64')
122123
for i in range(n):
123124
v = values[i]
124125
if c_is_list_like(v, False):
@@ -130,7 +131,7 @@ def explode(ndarray[object] values):
130131
else:
131132
counts[i] += 1
132133

133-
result = numpy.empty(counts.sum(), dtype='object')
134+
result = np.empty(counts.sum(), dtype='object')
134135
count = 0
135136
for i in range(n):
136137
v = values[i]
@@ -142,7 +143,7 @@ def explode(ndarray[object] values):
142143
count += 1
143144
else:
144145
# empty list-like, use a nan marker
145-
result[count] = numpy.nan
146+
result[count] = np.nan
146147
count += 1
147148
else:
148149
# replace with the existing scalar

0 commit comments

Comments
 (0)