Skip to content

Revert FrozenList changes (doc build slowdown, #15559) #15566

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 0 additions & 10 deletions doc/source/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ We could naturally group by either the ``A`` or ``B`` columns or both:
grouped = df.groupby('A')
grouped = df.groupby(['A', 'B'])

.. versionadded:: 0.20

If we also have a MultiIndex on columns ``A`` and ``B``, we can group by all
but the specified columns.

.. ipython:: python

df2 = df.set_index(['A', 'B'])
grouped = df2.groupby(level=df2.index.names.difference(['B'])

These will split the DataFrame on its index (rows). We could also split by the
columns:

Expand Down
2 changes: 0 additions & 2 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ New features

- Integration with the ``feather-format``, including a new top-level ``pd.read_feather()`` and ``DataFrame.to_feather()`` method, see :ref:`here <io.feather>`.
- ``.str.replace`` now accepts a callable, as replacement, which is passed to ``re.sub`` (:issue:`15055`)
- ``FrozenList`` has gained the ``.difference()`` setop method (:issue:`15475`)



Expand Down Expand Up @@ -536,7 +535,6 @@ Deprecations
- ``Series.sortlevel`` and ``DataFrame.sortlevel`` have been deprecated in favor of ``Series.sort_index`` and ``DataFrame.sort_index`` (:issue:`15099`)
- importing ``concat`` from ``pandas.tools.merge`` has been deprecated in favor of imports from the ``pandas`` namespace. This should only affect explict imports (:issue:`15358`)
- ``Series/DataFrame/Panel.consolidate()`` been deprecated as a public method. (:issue:`15483`)
- ``FrozenList`` addition (new object and inplace) have been deprecated in favor of the ``.union()`` method. (:issue: `15475`)
- The following top-level pandas functions have been deprecated and will be removed in a future version (:issue:`13790`)
* ``pd.pnow()``, replaced by ``Period.now()``
* ``pd.Term``, is removed, as it is not applicable to user code. Instead use in-line string expressions in the where clause when searching in HDFStore
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@ def construct_index_parts(idx, major=True):
minor_labels, minor_levels, minor_names = construct_index_parts(
self.minor_axis, major=False)

levels = list(major_levels) + list(minor_levels)
labels = list(major_labels) + list(minor_labels)
names = list(major_names) + list(minor_names)
levels = major_levels + minor_levels
labels = major_labels + minor_labels
names = major_names + minor_names

index = MultiIndex(levels=levels, labels=labels, names=names,
verify_integrity=False)
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def get_new_columns(self):
width = len(self.value_columns)
propagator = np.repeat(np.arange(width), stride)
if isinstance(self.value_columns, MultiIndex):
new_levels = self.value_columns.levels.union((self.removed_level,))
new_names = self.value_columns.names.union((self.removed_name,))
new_levels = self.value_columns.levels + (self.removed_level,)
new_names = self.value_columns.names + (self.removed_name,)

new_labels = [lab.take(propagator)
for lab in self.value_columns.labels]
Expand Down Expand Up @@ -806,7 +806,7 @@ def melt(frame, id_vars=None, value_vars=None, var_name=None,
for col in id_vars:
mdata[col] = np.tile(frame.pop(col).values, K)

mcolumns = list(id_vars) + list(var_name) + list([value_name])
mcolumns = id_vars + var_name + [value_name]

mdata[value_name] = frame.values.ravel('F')
for i, col in enumerate(var_name):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def str_extractall(arr, pat, flags=0):
if 0 < len(index_list):
from pandas import MultiIndex
index = MultiIndex.from_tuples(
index_list, names=arr.index.names.union(["match"]))
index_list, names=arr.index.names + ["match"])
else:
index = None
result = arr._constructor_expanddim(match_list, index=index,
Expand Down
24 changes: 3 additions & 21 deletions pandas/indexes/frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from pandas.types.cast import _coerce_indexer_dtype
from pandas.formats.printing import pprint_thing

import warnings


class FrozenList(PandasObject, list):

Expand All @@ -27,14 +25,11 @@ class FrozenList(PandasObject, list):
# typechecks

def __add__(self, other):
warnings.warn("__add__ is deprecated, use union(...)", FutureWarning)
return self.union(other)

def __iadd__(self, other):
warnings.warn("__iadd__ is deprecated, use union(...)", FutureWarning)
if isinstance(other, tuple):
other = list(other)
return super(FrozenList, self).__iadd__(other)
return self.__class__(super(FrozenList, self).__add__(other))

__iadd__ = __add__

# Python 2 compat
def __getslice__(self, i, j):
Expand Down Expand Up @@ -85,19 +80,6 @@ def __repr__(self):
__setitem__ = __setslice__ = __delitem__ = __delslice__ = _disabled
pop = append = extend = remove = sort = insert = _disabled

def union(self, other):
"""Returns a FrozenList with other concatenated to the end of self"""
if isinstance(other, tuple):
other = list(other)
return self.__class__(super(FrozenList, self).__add__(other))

def difference(self, other):
"""Returns a FrozenList with the same elements as self, but with elements
that are also in other removed."""
other = set(other)
temp = [x for x in self if x not in other]
return self.__class__(temp)


class FrozenNDArray(PandasObject, np.ndarray):

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_value_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def check_value_counts(df, keys, bins):

gr = df.groupby(keys, sort=isort)
right = gr['3rd'].apply(Series.value_counts, **kwargs)
right.index.names = right.index.names[:-1].union(['3rd'])
right.index.names = right.index.names[:-1] + ['3rd']

# have to sort on index because of unstable sort on values
left, right = map(rebuild_index, (left, right)) # xref GH9212
Expand Down
33 changes: 9 additions & 24 deletions pandas/tests/indexes/test_frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,20 @@ def setUp(self):
self.klass = FrozenList

def test_add(self):
q = FrozenList([1])
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
q = q + [2, 3]
expected = FrozenList([1, 2, 3])
self.check_result(q, expected)

def test_iadd(self):
q = FrozenList([1])
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
q += [2, 3]
expected = FrozenList([1, 2, 3])
self.check_result(q, expected)

def test_union(self):
result = self.container.union((1, 2, 3))
result = self.container + (1, 2, 3)
expected = FrozenList(self.lst + [1, 2, 3])
self.check_result(result, expected)

def test_difference(self):
result = self.container.difference([2])
expected = FrozenList([1, 3, 4, 5])
result = (1, 2, 3) + self.container
expected = FrozenList([1, 2, 3] + self.lst)
self.check_result(result, expected)

def test_difference_dupe(self):
result = FrozenList([1, 2, 3, 2]).difference([2])
expected = FrozenList([1, 3])
self.check_result(result, expected)
def test_inplace(self):
q = r = self.container
q += [5]
self.check_result(q, self.lst + [5])
# other shouldn't be mutated
self.check_result(r, self.lst)


class TestFrozenNDArray(CheckImmutable, CheckStringMixin, tm.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tools/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None):
" not have the same number of levels")

# also copies
names = list(names) + list(_get_consensus_names(indexes))
names = names + _get_consensus_names(indexes)

return MultiIndex(levels=levels, labels=label_list, names=names,
verify_integrity=False)
Expand Down
2 changes: 1 addition & 1 deletion test_fast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# https://github.com/pytest-dev/pytest/issues/1075
export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')

pytest pandas --skip-slow --skip-network -m "not single" -n 4 $@
pytest pandas --skip-slow --skip-network -m "not single" -n 4