8000 DEPR: Remove Panel-specific parts of io.pytables by jbrockmendel · Pull Request #25233 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEPR: Remove Panel-specific parts of io.pytables #25233

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 4 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
remove code only used by io.pytables for Panel
  • Loading branch information
jbrockmendel committed Feb 8, 2019
commit 43f5dd1af4ce2155a9af8263cdc41db673ac38a6
2 changes: 1 addition & 1 deletion pandas/core/internals/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from .blocks import ( # noqa:F401
_block2d_to_blocknd, _factor_indexer, _block_shape, # io.pytables
_block_shape, # io.pytables
_safe_reshape, # io.packers
make_block, # io.pytables, io.packers
FloatBlock, IntBlock, ComplexBlock, BoolBlock, ObjectBlock,
Expand Down
35 changes: 0 additions & 35 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3134,31 +3134,6 @@ def _merge_blocks(blocks, dtype=None, _can_consolidate=True):
return blocks


def _block2d_to_blocknd(values, placement, shape, labels, ref_items):
""" pivot to the labels shape """
panel_shape = (len(placement),) + shape

# TODO: lexsort depth needs to be 2!!

# Create observation selection vector using major and minor
# labels, for converting to panel format.
selector = _factor_indexer(shape[1:], labels)
mask = np.zeros(np.prod(shape), dtype=bool)
mask.put(selector, True)

if mask.all():
pvalues = np.empty(panel_shape, dtype=values.dtype)
else:
dtype, fill_value = maybe_promote(values.dtype)
pvalues = np.empty(panel_shape, dtype=dtype)
pvalues.fill(fill_value)

for i in range(len(placement)):
pvalues[i].flat[mask] = values[:, i]

return make_block(pvalues, placement=placement)


def _safe_reshape(arr, new_shape):
"""
If possible, reshape `arr` to have shape `new_shape`,
Expand All @@ -3181,16 +3156,6 @@ def _safe_reshape(arr, new_shape):
return arr


def _factor_indexer(shape, labels):
"""
given a tuple of shape and a list of Categorical labels, return the
expanded label indexer
"""
mult = np.array(shape)[::-1].cumprod()[::-1]
return ensure_platform_int(
np.sum(np.array(labels).T * np.append(mult, [1]), axis=1).T)


def _putmask_smart(v, m, n):
"""
Return a new ndarray, try to preserve dtype if possible.
Expand Down
0