|
26 | 26 | is_re, is_re_compilable, is_sparse, is_timedelta64_dtype, pandas_dtype)
|
27 | 27 | import pandas.core.dtypes.concat as _concat
|
28 | 28 | from pandas.core.dtypes.dtypes import (
|
29 |
| - CategoricalDtype, DatetimeTZDtype, ExtensionDtype, PandasExtensionDtype) |
| 29 | + CategoricalDtype, ExtensionDtype, PandasExtensionDtype) |
30 | 30 | from pandas.core.dtypes.generic import (
|
31 | 31 | ABCDataFrame, ABCDatetimeIndex, ABCExtensionArray, ABCIndexClass,
|
32 | 32 | ABCSeries)
|
@@ -1507,15 +1507,8 @@ def _nanpercentile(values, q, axis, **kw):
|
1507 | 1507 | len(values)).reshape(len(values),
|
1508 | 1508 | len(qs))
|
1509 | 1509 | else:
|
1510 |
| - |
1511 |
| - try: |
1512 |
| - result = _nanpercentile(values, np.array(qs) * 100, |
1513 |
| - axis=axis, **kw) |
1514 |
| - except ValueError: |
1515 |
| - |
1516 |
| - # older numpies don't handle an array for q |
1517 |
| - result = [_nanpercentile(values, q * 100, |
1518 |
| - axis=axis, **kw) for q in qs] |
| 1510 | + result = _nanpercentile(values, np.array(qs) * 100, |
| 1511 | + axis=axis, **kw) |
1519 | 1512 |
|
1520 | 1513 | result = np.array(result, copy=False)
|
1521 | 1514 | if self.ndim > 1:
|
@@ -1639,13 +1632,6 @@ def shape(self):
|
1639 | 1632 | return (len(self.values)),
|
1640 | 1633 | return (len(self.mgr_locs), len(self.values))
|
1641 | 1634 |
|
1642 |
| - def get_values(self, dtype=None): |
1643 |
| - """ need to to_dense myself (and always return a ndim sized object) """ |
1644 |
| - values = self.values.to_dense() |
1645 |
| - if values.ndim == self.ndim - 1: |
1646 |
| - values = values.reshape((1,) + values.shape) |
1647 |
| - return values |
1648 |
| - |
1649 | 1635 | def iget(self, col):
|
1650 | 1636 |
|
1651 | 1637 | if self.ndim == 2 and isinstance(col, tuple):
|
@@ -1700,49 +1686,9 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0,
|
1700 | 1686 | new_values = self._try_coerce_result(new_values)
|
1701 | 1687 | return [self.make_block(values=new_values)]
|
1702 | 1688 |
|
1703 |
| - def _slice(self, slicer): |
1704 |
| - """ return a slice of my values (but densify first) """ |
1705 |
| - return self.get_values()[slicer] |
1706 |
| - |
1707 | 1689 | def _try_cast_result(self, result, dtype=None):
|
1708 | 1690 | return result
|
1709 | 1691 |
|
1710 |
| - def _unstack(self, unstacker_func, new_columns, n_rows, fill_value): |
1711 |
| - """Return a list of unstacked blocks of self |
1712 |
| -
|
1713 |
| - Parameters |
1714 |
| - ---------- |
1715 |
| - unstacker_func : callable |
1716 |
| - Partially applied unstacker. |
1717 |
| - new_columns : Index |
1718 |
| - All columns of the unstacked BlockManager. |
1719 |
| - n_rows : int |
1720 |
| - Only used in ExtensionBlock.unstack |
1721 |
| - fill_value : int |
1722 |
| - Only used in ExtensionBlock.unstack |
1723 |
| -
|
1724 |
| - Returns |
1725 |
| - ------- |
1726 |
| - blocks : list of Block |
1727 |
| - New blocks of unstacked values. |
1728 |
| - mask : array_like of bool |
1729 |
| - The mask of columns of `blocks` we should keep. |
1730 |
| - """ |
1731 |
| - # NonConsolidatable blocks can have a single item only, so we return |
1732 |
| - # one block per item |
1733 |
| - unstacker = unstacker_func(self.values.T) |
1734 |
| - |
1735 |
| - new_placement, new_values, mask = self._get_unstack_items( |
1736 |
| - unstacker, new_columns |
1737 |
| - ) |
1738 |
| - |
1739 |
| - new_values = new_values.T[mask] |
1740 |
| - new_placement = new_placement[mask] |
1741 |
| - |
1742 |
| - blocks = [self.make_block_same_class(vals, [place]) |
1743 |
| - for vals, place in zip(new_values, new_placement)] |
1744 |
| - return blocks, mask |
1745 |
| - |
1746 | 1692 | def _get_unstack_items(self, unstacker, new_columns):
|
1747 | 1693 | """
|
1748 | 1694 | 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,
|
2330 | 2276 | i8values = i8values[..., slicer]
|
2331 | 2277 |
|
2332 | 2278 | from pandas.io.formats.format import _get_format_datetime64_from_values
|
2333 |
| - format = _get_format_datetime64_from_values(values, date_format) |
| 2279 | + fmt = _get_format_datetime64_from_values(values, date_format) |
2334 | 2280 |
|
2335 | 2281 | result = tslib.format_array_from_datetime(
|
2336 | 2282 | i8values.ravel(), tz=getattr(self.values, 'tz', None),
|
2337 |
| - format=format, na_rep=na_rep).reshape(i8values.shape) |
| 2283 | + format=fmt, na_rep=na_rep).reshape(i8values.shape) |
2338 | 2284 | return np.atleast_2d(result)
|
2339 | 2285 |
|
2340 | 2286 | def should_store(self, value):
|
@@ -2400,8 +2346,6 @@ def _maybe_coerce_values(self, values, dtype=None):
|
2400 | 2346 | values = self._holder(values)
|
2401 | 2347 |
|
2402 | 2348 | if dtype is not None:
|
2403 |
| - if isinstance(dtype, compat.string_types): |
2404 |
| - dtype = DatetimeTZDtype.construct_from_string(dtype) |
2405 | 2349 | values = type(values)(values, dtype=dtype)
|
2406 | 2350 |
|
2407 | 2351 | if values.tz is None:
|
|
0 commit comments