1616 iNaT ,
1717)
1818from pandas ._libs .tslibs .timezones import tz_compare
19- from pandas ._typing import Dtype
19+ from pandas ._typing import Dtype , DtypeObj
2020from pandas .util ._validators import validate_bool_kwarg
2121
2222from pandas .core .dtypes .common import (
@@ -246,14 +246,27 @@ def trans(x):
246246 return result
247247
248248
249- def maybe_cast_result (result , obj , numeric_only : bool = False , how : str = "" ):
249+ def maybe_cast_result (
250+ result , obj : ABCSeries , numeric_only : bool = False , how : str = ""
251+ ):
250252 """
251- Try to cast the result to the desired type,
252- we may have roundtripped through object in the mean-time.
253+ Try casting result to a different type if appropriate
253254
254- If numeric_only is True, then only try to cast numerics
255- and not datetimelikes.
255+ Parameters
256+ ----------
257+ result : array-like
258+ Result to cast.
259+ obj : ABCSeries
260+ Input series from which result was calculated.
261+ numeric_only : bool, default False
262+ Whether to cast only numerics or datetimes as well.
263+ how : str, default ""
264+ If result was aggregated, how the aggregation was performed.
256265
266+ Returns
267+ -------
268+ result : array-like
269+ result maybe casted to the dtype.
257270 """
258271 if obj .ndim > 1 :
259272 dtype = obj ._values .dtype
@@ -278,21 +291,22 @@ def maybe_cast_result(result, obj, numeric_only: bool = False, how: str = ""):
278291 return result
279292
280293
281- def maybe_cast_result_dtype (dtype , how ) :
294+ def maybe_cast_result_dtype (dtype : DtypeObj , how : str ) -> DtypeObj :
282295 """
283- Get the desired dtype of a groupby result based on the
284- input dtype and how the aggregation is done .
296+ Get the desired dtype of a result based on the
297+ input dtype and how it was computed .
285298
286299 Parameters
287300 ----------
288- dtype : dtype, type
289- The input dtype of the groupby .
301+ dtype : DtypeObj
302+ Input dtype.
290303 how : str
291- How the aggregation is performed .
304+ How the result was computed .
292305
293306 Returns
294307 -------
295- The desired dtype of the aggregation result.
308+ DtypeObj
309+ The desired dtype of the aggregation result.
296310 """
297311 d = {
298312 (np .dtype (np .bool ), "add" ): np .dtype (np .int64 ),
0 commit comments