8000 ExtensionArray.take default implementation by TomAugspurger · Pull Request #20814 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ExtensionArray.take default implementation #20814

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 32 commits into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fb3c234
[WIP]: ExtensionArray.take default implementation
TomAugspurger Apr 24, 2018
dacd98e
Moves
TomAugspurger Apr 24, 2018
0be9ec6
non-internals changes
TomAugspurger Apr 24, 2018
08f2479
Fixup JSON take
TomAugspurger Apr 25, 2018
eba137f
More internals hacking
TomAugspurger Apr 25, 2018
67ba9dd
more with default fill value
TomAugspurger Apr 25, 2018
37915e9
Merge remote-tracking branch 'upstream/master' into ea-take
TomAugspurger Apr 25, 2018
c721915
Removed default_fill_value
TomAugspurger Apr 25, 2018
125ca0b
Simplify
TomAugspurger Apr 25, 2018
b7ae0bc
revert combine change
TomAugspurger Apr 25, 2018
338566f
Upcasting
TomAugspurger Apr 25, 2018
31cd304
pep8
TomAugspurger Apr 25, 2018
05d8844
Updated docs
TomAugspurger Apr 25, 2018
69e7fe7
Updates
TomAugspurger Apr 25, 2018
449983b
Linting
TomAugspurger Apr 25, 2018
c449afd
Bounds checking
TomAugspurger Apr 25, 2018
82cad8b
Stale comment
TomAugspurger Apr 25, 2018
d5470a0
Fixed reorder
TomAugspurger Apr 25, 2018
bbcbf19
Cleanup
TomAugspurger Apr 25, 2018
1a4d987
Pass an array
TomAugspurger Apr 25, 2018
fc729d6
Fixed editor
TomAugspurger Apr 25, 2018
74b2c09
Added verisonadded
TomAugspurger Apr 26, 2018
5db6624
Doc and move tests
TomAugspurger Apr 26, 2018
741f284
Merge remote-tracking branch 'upstream/master' into ea-take
TomAugspurger Apr 26, 2018
fbc4425
Updates
TomAugspurger Apr 26, 2018
f3b91ca
doc fixup
TomAugspurger Apr 26, 2018
eecd632
Skip categorical take tests
TomAugspurger Apr 26, 2018
9a6c7d4
Doc updates
TomAugspurger Apr 27, 2018
7c4f625
Merge remote-tracking branch 'upstream/master' into ea-take
TomAugspurger Apr 27, 2018
eb43fa4
Really truly fix it hopefully.
TomAugspurger Apr 27, 2018
6858409
Added note
TomAugspurger Apr 27, 2018
ec0cecd
Updates
TomAugspurger Apr 27, 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
more with default fill value
  • Loading branch information
TomAugspurger committed Apr 25, 2018
commit 67ba9ddb0c8dec7f88a7ce14387898b552afe355
4 changes: 3 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pandas._libs import tslib, lib
from pandas._libs.tslib import iNaT
from pandas.compat import string_types, text_type, PY3
from pandas.compat import string_types, text_type, PY3, _default_fill_value
from .common import (_ensure_object, is_bool, is_integer, is_float,
is_complex, is_datetimetz, is_categorical_dtype,
is_datetimelike,
Expand Down Expand Up @@ -255,6 +255,8 @@ def changeit():


def maybe_promote(dtype, fill_value=np.nan):
if fill_value is _default_fill_value:
fill_value = np.nan

# if we passed an array here, determine the fill value by dtype
if isinstance(fill_value, np.ndarray):
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7263,6 +7263,9 @@ def _align_frame(self, other, join='outer', axis=None, level=None,
clidx, cridx = None, None

is_series = isinstance(self, ABCSeries)
if fill_value is _default_fill_value:
# XXX: per-column?
fill_value = np.nan

if axis is None or axis == 0:
if not self.index.equals(other.index):
Expand Down
12 changes: 9 additions & 3 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4417,9 +4417,15 @@ def reindex_indexer(self, new_axis, indexer, axis, fill_value=None,
else:
if fill_value is None:
fill_value = _default_fill_value
new_blocks = [blk.take_nd(indexer, axis=axis, fill_tuple=(
fill_value if fill_value is not _default_fill_value else blk.fill_value,))
for blk in self.blocks]

new_blocks = []
for blk in self.blocks:
if fill_value is not _default_fill_value:
fill_tuple = (fill_value,)
else:
fill_tuple = (blk.fill_value,)
new_blocks = [blk.take_nd(indexer, axis=axis, fill_tuple=fill_tuple)
for blk in self.blocks]

new_axes = list(self.axes)
new_axes[axis] = new_axis
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3217,7 +3217,7 @@ def _reindex_indexer(self, new_index, indexer, copy):
return self

from pandas.core.dtypes.missing import na_value_for_dtype
fill_value = na_value_for_dtype(self.dtype)
fill_value = na_value_for_dtype(self.dtype, compat=False)
new_values = algorithms.take(self._values, indexer,
fill_value=fill_value)
return self._constructor(new_values, index=new_index)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/sparse/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# pylint: disable=E1101,E1103,W0231,E0202

import warnings
from pandas.compat import lmap
from pandas.compat import lmap, _default_fill_value
from pandas import compat
import numpy as np

Expand Down Expand Up @@ -690,7 +690,7 @@ def _reindex_columns(self, columns, method, copy, level, fill_value=None,
53E5 if level is not None:
raise TypeError('Reindex by level not supported for sparse')

if notna(fill_value):
if not (isna(fill_value) or fill_value is _default_fill_value):
raise NotImplementedError("'fill_value' argument is not supported")

if limit:
Expand Down
0