Skip to content

standardize signature for Index reductions, implement nanmean for datetime64 dtypes #24293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Dec 29, 2018
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f38ffe1
standardize signature for Index reductions, implement nanmean for dat…
jbrockmendel Dec 15, 2018
04cf1f7
suppress warnings
jbrockmendel Dec 15, 2018
3efab79
requested edits
jbrockmendel Dec 15, 2018
a652439
implement view
jbrockmendel Dec 15, 2018
ce760d3
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 19, 2018
2380af6
pass skipna, tests
jbrockmendel Dec 19, 2018
4157f0b
fixup isort
jbrockmendel Dec 20, 2018
50642ae
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 23, 2018
0baedf3
fixup rebase screwups
jbrockmendel Dec 23, 2018
6e0e69f
move len-self checks
jbrockmendel Dec 23, 2018
e2c301b
fixup more rebase screwups
jbrockmendel Dec 23, 2018
fce67ac
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 24, 2018
4b4979f
do values viewing in one place
jbrockmendel Dec 24, 2018
82b8cdf
unpack Series
jbrockmendel Dec 27, 2018
ffe6ada
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 27, 2018
7f7693f
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 28, 2018
07c3102
implement _extract_datetimelike_values_and_dtype
jbrockmendel Dec 28, 2018
6c93410
fix mask
jbrockmendel Dec 28, 2018
4620c56
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 28, 2018
4777b75
requested docstring edits, remoe duplicated view
jbrockmendel Dec 28, 2018
aa4028a
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Dec 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do values viewing in one place
  • Loading branch information
jbrockmendel committed Dec 24, 2018
commit 4b4979f5682bc556e360d8514a68fb8c13171fd1
21 changes: 12 additions & 9 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,24 @@ def _get_values(values, skipna, fill_value=None, fill_value_typ=None,
if necessary copy and mask using the specified fill_value
copy = True will force the copy
"""
orig_values = values
values = com.values_from_object(values)

if is_datetime64tz_dtype(values):
# com.values_from_object returns M8[ns] dtype instead of tz-aware,
# so this case must be handled separately from the rest
dtype = values.dtype
values = np.array(values.asi8)
else:
values = com.values_from_object(values)
dtype = values.dtype

values = _view_if_needed(values)

if mask is None:
if isfinite:
mask = _isfinite(values)
else:
mask = isna(values)

dtype = values.dtype
if is_datetime64tz_dtype(orig_values):
dtype = orig_values.dtype

values = getattr(values, 'asi8', values)
dtype_ok = _na_ok_dtype(dtype)

# get our fill value (in case we need to provide an alternative
Expand All @@ -237,8 +241,6 @@ def _get_values(values, skipna, fill_value=None, fill_value_typ=None,
elif copy:
values = values.copy()

values = _view_if_needed(values)

# return a platform independent precision dtype
dtype_max = dtype
if is_integer_dtype(dtype) or is_bool_dtype(dtype):
Expand All @@ -265,6 +267,7 @@ def _na_ok_dtype(dtype):


def _view_if_needed(values):
values = getattr(values, 'asi8', values)
if is_datetime_or_timedelta_dtype(values):
return values.view(np.int64)
return values
Expand Down