We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3085f9f commit e97a56eCopy full SHA for e97a56e
pandas/_typing.py
@@ -83,8 +83,7 @@
83
84
# numpy compatible types
85
NumpyValueArrayLike: TypeAlias = ScalarLike_co | npt.ArrayLike
86
- # Name "npt._ArrayLikeInt_co" is not defined [name-defined]
87
- NumpySorter: TypeAlias = npt._ArrayLikeInt_co | None # type: ignore[name-defined]
+ NumpySorter: TypeAlias = npt._ArrayLikeInt_co | None
88
89
90
P = ParamSpec("P")
pandas/core/algorithms.py
@@ -215,14 +215,15 @@ def _reconstruct_data(
215
# that values.dtype == dtype
216
cls = dtype.construct_array_type()
217
218
- # error: Incompatible types in assignment (expression has type
219
- # "ExtensionArray", variable has type "ndarray[Any, Any]")
220
- values = cls._from_sequence(values, dtype=dtype) # type: ignore[assignment]
221
-
222
- else:
223
- values = values.astype(dtype, copy=False)
224
225
- return values
+ # error: Incompatible return value type
+ # (got "ExtensionArray",
+ # expected "ndarray[tuple[Any, ...], dtype[Any]]")
+ return cls._from_sequence(values, dtype=dtype) # type: ignore[return-value]
+
+ # (got "ndarray[tuple[Any, ...], dtype[Any]]",
+ # expected "ExtensionArray")
226
+ return values.astype(dtype, copy=False) # type: ignore[return-value]
227
228
229
def _ensure_arraylike(values, func_name: str) -> ArrayLike:
pandas/core/array_algos/quantile.py
@@ -102,7 +102,7 @@ def quantile_with_mask(
102
interpolation=interpolation,
103
)
104
105
- result = np.asarray(result)# type: ignore[assignment]
+ result = np.asarray(result)
106
result = result.T
107
108
return result
pandas/core/arrays/_mixins.py
@@ -151,7 +151,9 @@ def view(self, dtype: Dtype | None = None) -> ArrayLike:
151
152
td64_values = arr.view(dtype)
153
return TimedeltaArray._simple_new(td64_values, dtype=dtype)
154
- return arr.view(dtype=dtype)
+ # error: Argument "dtype" to "view" of "ndarray" has incompatible type
155
+ # "ExtensionDtype | dtype[Any]"; expected "dtype[Any] | _HasDType[dtype[Any]]"
156
+ return arr.view(dtype=dtype) # type: ignore[arg-type]
157
158
def take(
159
self,
pandas/core/arrays/arrow/_arrow_utils.py
@@ -44,7 +44,7 @@ def pyarrow_array_to_numpy_and_mask(
44
mask = pyarrow.BooleanArray.from_buffers(
45
pyarrow.bool_(), len(arr), [None, bitmask], offset=arr.offset
46
47
- mask = np.asarray(mask)# type: ignore[assignment]
+ mask = np.asarray(mask)
48
else:
49
mask = np.ones(len(arr), dtype=bool)
50
return data, mask
pandas/core/arrays/arrow/array.py
@@ -657,7 +657,7 @@ def _box_pa_array(
657
):
658
arr_value = np.asarray(value, dtype=object)
659
# similar to isna(value) but exclude NaN, NaT, nat-like, nan-like
660
- mask = is_pdna_or_none(arr_value)# type: ignore[assignment]
+ mask = is_pdna_or_none(arr_value)
661
662
try:
663
pa_array = pa.array(value, type=pa_type, mask=mask)
@@ -2738,7 +2738,7 @@ def _str_get_dummies(self, sep: str = "|", dtype: NpDtype | None = None):
2738
dummies_dtype = np.bool_
2739
dummies = np.zeros(n_rows * n_cols, dtype=dummies_dtype)
2740
dummies[indices] = True
2741
- dummies = dummies.reshape((n_rows, n_cols))# type: ignore[assignment]
+ dummies = dummies.reshape((n_rows, n_cols))
2742
result = self._from_pyarrow_array(pa.array(list(dummies)))
2743
return result, uniques_sorted.to_pylist()
2744
pandas/core/arrays/categorical.py
@@ -1869,7 +1869,7 @@ def value_counts(self, dropna: bool = True) -> Series:
1869
count = np.bincount(obs, minlength=ncat or 0)
1870
1871
count = np.bincount(np.where(mask, code, ncat))
1872
- ix = np.append(ix, -1)# type: ignore[assignment]
+ ix = np.append(ix, -1)
1873
1874
ix = coerce_indexer_dtype(ix, self.dtype.categories)
1875
ix_categorical = self._from_backing_data(ix)
pandas/core/arrays/datetimes.py
@@ -804,7 +804,11 @@ def _add_offset(self, offset: BaseOffset) -> Self:
804
805
res_values = offset._apply_array(values._ndarray)
806
if res_values.dtype.kind == "i":
807
- res_values = res_values.view(values.dtype)
+ # error: Argument 1 to "view" of "ndarray" has
808
+ # incompatible type
809
+ # "dtype[datetime64[date | int | None]] | DatetimeTZDtype";
810
+ # expected "dtype[Any] | _HasDType[dtype[Any]]" [arg-type]
811
+ res_values = res_values.view(values.dtype) # type: ignore[arg-type]
812
except NotImplementedError:
813
if get_option("performance_warnings"):
814
warnings.warn(
pandas/core/arrays/string_.py
@@ -764,7 +764,7 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
764
result = super()._cast_pointwise_result(values)
765
if isinstance(result.dtype, StringDtype):
766
# Ensure we retain our same na_value/storage
767
- result = result.astype(self.dtype)# type: ignore[call-overload]
+ result = result.astype(self.dtype)
768
769
770
@classmethod
pandas/core/groupby/groupby.py
@@ -1886,7 +1886,7 @@ def _apply_filter(self, indices, dropna):
1886
mask.fill(False)
1887
mask[indices.astype(int)] = True
1888
# mask fails to broadcast when passed to where; broadcast manually.
1889
- mask = np.tile(mask, list(self._selected_obj.shape[1:]) + [1]).T# type: ignore[assignment]
+ mask = np.tile(mask, list(self._selected_obj.shape[1:]) + [1]).T
1890
filtered = self._selected_obj.where(mask) # Fill with NaNs.
1891
return filtered
1892
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments