Skip to content

Commit 6525fc6

Browse files
authored
1 parent 5e503b4 commit 6525fc6

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

pandas/core/nanops.py

+19-18
Original file line numberDiff line numberDiff line change
@@ -692,20 +692,20 @@ def nanmean(
692692
values, mask, dtype, dtype_max, _ = _get_values(
693693
values, skipna, fill_value=0, mask=mask
694694
)
695-
dtype_sum = dtype_max
695+
# dtype_sum = dtype_max
696696
dtype_count = np.dtype(np.float64)
697697

698698
# not using needs_i8_conversion because that includes period
699-
if dtype.kind in ["m", "M"]:
700-
dtype_sum = np.dtype(np.float64)
701-
elif is_integer_dtype(dtype):
702-
dtype_sum = np.dtype(np.float64)
703-
elif is_float_dtype(dtype):
704-
dtype_sum = dtype
705-
dtype_count = dtype
699+
# if dtype.kind in ["m", "M"]:
700+
# dtype_sum = np.dtype(np.float64)
701+
# elif is_integer_dtype(dtype):
702+
# dtype_sum = np.dtype(np.float64)
703+
# elif is_float_dtype(dtype):
704+
# dtype_sum = dtype
705+
# dtype_count = dtype
706706

707707
count = _get_counts(values.shape, mask, axis, dtype=dtype_count)
708-
the_sum = _ensure_numeric(values.sum(axis, dtype=dtype_sum))
708+
the_sum = _ensure_numeric(values.sum(axis, dtype=np.float64))
709709

710710
if axis is not None and getattr(the_sum, "ndim", False):
711711
count = cast(np.ndarray, count)
@@ -911,9 +911,10 @@ def nanstd(
911911

912912
orig_dtype = values.dtype
913913
values, mask, _, _, _ = _get_values(values, skipna, mask=mask)
914-
915914
result = np.sqrt(nanvar(values, axis=axis, skipna=skipna, ddof=ddof, mask=mask))
916-
return _wrap_results(result, orig_dtype)
915+
# return _wrap_results(result, np.orig_dtype)
916+
return result
917+
917918

918919

919920
@disallow("M8", "m8")
@@ -961,10 +962,10 @@ def nanvar(
961962
if mask is not None:
962963
values[mask] = np.nan
963964

964-
if is_float_dtype(values.dtype):
965-
count, d = _get_counts_nanvar(values.shape, mask, axis, ddof, values.dtype)
966-
else:
967-
count, d = _get_counts_nanvar(values.shape, mask, axis, ddof)
965+
# if is_float_dtype(values.dtype):
966+
# count, d = _get_counts_nanvar(values.shape, mask, axis, ddof, values.dtype)
967+
# else:
968+
count, d = _get_counts_nanvar(values.shape, mask, axis, ddof)
968969

969970
if skipna and mask is not None:
970971
values = values.copy()
@@ -979,16 +980,16 @@ def nanvar(
979980
avg = _ensure_numeric(values.sum(axis=axis, dtype=np.float64)) / count
980981
if axis is not None:
981982
avg = np.expand_dims(avg, axis)
982-
sqr = _ensure_numeric((avg - values) ** 2)
983+
sqr = _ensure_numeric((np.subtract(avg , values,dtype=np.float64)) ** 2)
983984
if mask is not None:
984985
np.putmask(sqr, mask, 0)
985986
result = sqr.sum(axis=axis, dtype=np.float64) / d
986987

987988
# Return variance as np.float64 (the datatype used in the accumulator),
988989
# unless we were dealing with a float array, in which case use the same
989990
# precision as the original values array.
990-
if is_float_dtype(dtype):
991-
result = result.astype(dtype, copy=False)
991+
# if is_float_dtype(dtype):
992+
# result = result.astype(dtype, copy=False)
992993
return result
993994

994995

0 commit comments

Comments
 (0)