-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Remove unhittable methods in internals #24594
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
Changes from all commits
b744a69
2019a5b
d31338c
c8b3323
c0b544e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
is_re, is_re_compilable, is_sparse, is_timedelta64_dtype, pandas_dtype) | ||
import pandas.core.dtypes.concat as _concat | ||
from pandas.core.dtypes.dtypes import ( | ||
CategoricalDtype, DatetimeTZDtype, ExtensionDtype, PandasExtensionDtype) | ||
CategoricalDtype, ExtensionDtype, PandasExtensionDtype) | ||
from pandas.core.dtypes.generic import ( | ||
ABCDataFrame, ABCDatetimeIndex, ABCExtensionArray, ABCIndexClass, | ||
ABCSeries) | ||
|
@@ -1507,15 +1507,8 @@ def _nanpercentile(values, q, axis, **kw): | |
len(values)).reshape(len(values), | ||
len(qs)) | ||
else: | ||
|
||
try: | ||
result = _nanpercentile(values, np.array(qs) * 100, | ||
axis=axis, **kw) | ||
except ValueError: | ||
|
||
# older numpies don't handle an array for q | ||
result = [_nanpercentile(values, q * 100, | ||
axis=axis, **kw) for q in qs] | ||
result = _nanpercentile(values, np.array(qs) * 100, | ||
axis=axis, **kw) | ||
|
||
result = np.array(result, copy=False) | ||
if self.ndim > 1: | ||
|
@@ -1639,13 +1632,6 @@ def shape(self): | |
return (len(self.values)), | ||
return (len(self.mgr_locs), len(self.values)) | ||
|
||
def get_values(self, dtype=None): | ||
""" need to to_dense myself (and always return a ndim sized object) """ | ||
values = self.values.to_dense() | ||
if values.ndim == self.ndim - 1: | ||
values = values.reshape((1,) + values.shape) | ||
return values | ||
|
||
def iget(self, col): | ||
|
||
if self.ndim == 2 and isinstance(col, tuple): | ||
|
@@ -1700,49 +1686,9 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0, | |
new_values = self._try_coerce_result(new_values) | ||
return [self.make_block(values=new_values)] | ||
|
||
def _slice(self, slicer): | ||
""" return a slice of my values (but densify first) """ | ||
return self.get_values()[slicer] | ||
|
||
def _try_cast_result(self, result, dtype=None): | ||
return result | ||
|
||
def _unstack(self, unstacker_func, new_columns, n_rows, fill_value): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this and the two methods above are in NonConsolodateableMixin, which is now only mixed in to ExtensionBlock, which directly defines these three methods. |
||
"""Return a list of unstacked blocks of self | ||
|
||
Parameters | ||
---------- | ||
unstacker_func : callable | ||
Partially applied unstacker. | ||
new_columns : Index | ||
All columns of the unstacked BlockManager. | ||
n_rows : int | ||
Only used in ExtensionBlock.unstack | ||
fill_value : int | ||
Only used in ExtensionBlock.unstack | ||
|
||
Returns | ||
------- | ||
blocks : list of Block | ||
New blocks of unstacked values. | ||
mask : array_like of bool | ||
The mask of columns of `blocks` we should keep. | ||
""" | ||
# NonConsolidatable blocks can have a single item only, so we return | ||
# one block per item | ||
unstacker = unstacker_func(self.values.T) | ||
|
||
new_placement, new_values, mask = self._get_unstack_items( | ||
unstacker, new_columns | ||
) | ||
|
||
new_values = new_values.T[mask] | ||
new_placement = new_placement[mask] | ||
|
||
blocks = [self.make_block_same_class(vals, [place]) | ||
for vals, place in zip(new_values, new_placement)] | ||
return blocks, mask | ||
|
||
def _get_unstack_items(self, unstacker, new_columns): | ||
""" | ||
Get the placement, values, and mask for a Block unstack. | ||
|
@@ -2330,11 +2276,11 @@ def to_native_types(self, slicer=None, na_rep=None, date_format=None, | |
i8values = i8values[..., slicer] | ||
|
||
from pandas.io.formats.format import _get_format_datetime64_from_values | ||
format = _get_format_datetime64_from_values(values, date_format) | ||
fmt = _get_format_datetime64_from_values(values, date_format) | ||
|
||
result = tslib.format_array_from_datetime( | ||
i8values.ravel(), tz=getattr(self.values, 'tz', None), | ||
format=format, na_rep=na_rep).reshape(i8values.shape) | ||
format=fmt, na_rep=na_rep).reshape(i8values.shape) | ||
return np.atleast_2d(result) | ||
|
||
def should_store(self, value): | ||
|
@@ -2400,8 +2346,6 @@ def _maybe_coerce_values(self, values, dtype=None): | |
values = self._holder(values) | ||
|
||
if dtype is not None: | ||
if isinstance(dtype, compat.string_types): | ||
dtype = DatetimeTZDtype.construct_from_string(dtype) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let the DatetimeArray constructor handle this |
||
values = type(values)(values, dtype=dtype) | ||
|
||
if values.tz is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually just assuming here that the relevant old numpies can by dropped. @h-vetinari any idea on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbrockmendel
Sorry I was too late too see this. Can't really tell from first glance what's going on, but can have a second look if desired.