Skip to content

Commit d494717

Browse files
authored
REF: Use nonzero in place of argwhere (#31853)
1 parent 66440b2 commit d494717

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

pandas/io/stata.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1671,17 +1671,13 @@ def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFra
16711671
continue
16721672

16731673
if convert_missing: # Replacement follows Stata notation
1674-
missing_loc = np.argwhere(missing._ndarray_values)
1674+
missing_loc = np.nonzero(missing._ndarray_values)[0]
16751675
umissing, umissing_loc = np.unique(series[missing], return_inverse=True)
16761676
replacement = Series(series, dtype=np.object)
16771677
for j, um in enumerate(umissing):
16781678
missing_value = StataMissingValue(um)
16791679

16801680
loc = missing_loc[umissing_loc == j]
1681-
if loc.ndim == 2 and loc.shape[1] == 1:
1682-
# GH#31813 avoid trying to set Series values with wrong
1683-
# dimension
1684-
loc = loc[:, 0]
16851681
replacement.iloc[loc] = missing_value
16861682
else: # All replacements are identical
16871683
dtype = series.dtype

0 commit comments

Comments
 (0)