From e5cc61bf29fb133e40d6998126977ba000ffe1d6 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Mon, 10 Feb 2020 16:18:24 +0000 Subject: [PATCH] REF: Use nonzero in place of argwhere Use nonzero to preserve 1d of Series xref #31813 --- pandas/io/stata.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index d651fe9f67773..4e93b62a96ef2 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -1671,17 +1671,13 @@ def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFra continue if convert_missing: # Replacement follows Stata notation - missing_loc = np.argwhere(missing._ndarray_values) + missing_loc = np.nonzero(missing._ndarray_values)[0] umissing, umissing_loc = np.unique(series[missing], return_inverse=True) replacement = Series(series, dtype=np.object) for j, um in enumerate(umissing): missing_value = StataMissingValue(um) loc = missing_loc[umissing_loc == j] - if loc.ndim == 2 and loc.shape[1] == 1: - # GH#31813 avoid trying to set Series values with wrong - # dimension - loc = loc[:, 0] replacement.iloc[loc] = missing_value else: # All replacements are identical dtype = series.dtype