Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ee3ec7a

Browse files
committedFeb 26, 2017
Changed internal references to consolidate and updated tests
1 parent 3b242b4 commit ee3ec7a

10 files changed

+30
-30
lines changed
 

‎pandas/core/generic.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2875,14 +2875,6 @@ def f():
28752875
self._protect_consolidate(f)
28762876

28772877
def _consolidate(self, inplace=False):
2878-
# 15483
2879-
warnings.warn("consolidate is deprecated and will be removed in a "
2880-
"future release.", DeprecationWarning, stacklevel=2)
2881-
f = lambda: self._data.consolidate()
2882-
cons_data = self._protect_consolidate(f)
2883-
return self._constructor(cons_data).__finalize__(self)
2884-
2885-
def consolidate(self, inplace=False):
28862878
"""
28872879
DEPRECATED:
28882880
@@ -2902,7 +2894,15 @@ def consolidate(self, inplace=False):
29022894
if inplace:
29032895
self._consolidate_inplace()
29042896
else:
2905-
return self._consolidate(inplace=False)
2897+
f = lambda: self._data.consolidate()
2898+
cons_data = self._protect_consolidate(f)
2899+
return self._constructor(cons_data).__finalize__(self)
2900+
2901+
def consolidate(self, inplace=False):
2902+
# 15483
2903+
warnings.warn("consolidate is deprecated and will be removed in a "
2904+
"future release.", DeprecationWarning)
2905+
return self._consolidate(inplace)
29062906

29072907
@property
29082908
def _is_mixed_type(self):

‎pandas/core/groupby.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3893,7 +3893,7 @@ def _wrap_aggregated_output(self, output, names=None):
38933893
if not self.as_index:
38943894
result = DataFrame(output, columns=output_keys)
38953895
self._insert_inaxis_grouper_inplace(result)
3896-
result = result.consolidate()
3896+
result = result._consolidate()
38973897
else:
38983898
index = self.grouper.result_index
38993899
result = DataFrame(output, index=index, columns=output_keys)
@@ -3913,7 +3913,7 @@ def _wrap_agged_blocks(self, items, blocks):
39133913
result = DataFrame(mgr)
39143914

39153915
self._insert_inaxis_grouper_inplace(result)
3916-
result = result.consolidate()
3916+
result = result._consolidate()
39173917
else:
39183918
index = self.grouper.result_index
39193919
mgr = BlockManager(blocks, [items, index])

‎pandas/io/pytables.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def func(_start, _stop, _where):
835835

836836
# concat and return
837837
return concat(objs, axis=axis,
838-
verify_integrity=False).consolidate()
838+
verify_integrity=False)._consolidate()
839839

840840
# create the iterator
841841
it = TableIterator(self, s, func, where=where, nrows=nrows,
@@ -2861,7 +2861,7 @@ def write(self, obj, **kwargs):
28612861
super(BlockManagerFixed, self).write(obj, **kwargs)
28622862
data = obj._data
28632863
if not data.is_consolidated():
2864-
data = data.consolidate()
2864+
data = data._consolidate()
28652865

28662866
self.attrs.ndim = data.ndim
28672867
for i, ax in enumerate(data.axes):
@@ -3442,7 +3442,7 @@ def get_blk_items(mgr, blocks):
34423442
return [mgr.items.take(blk.mgr_locs) for blk in blocks]
34433443

34443444
# figure out data_columns and get out blocks
3445-
block_obj = self.get_object(obj).consolidate()
3445+
block_obj = self.get_object(obj)._consolidate()
34463446
blocks = block_obj._data.blocks
34473447
blk_items = get_blk_items(block_obj._data, blocks)
34483448
if len(self.non_index_axes):
@@ -3809,7 +3809,7 @@ def read(self, where=None, columns=None, **kwargs):
38093809
if len(objs) == 1:
38103810
wp = objs[0]
38113811
else:
3812-
wp = concat(objs, axis=0, verify_integrity=False).consolidate()
3812+
wp = concat(objs, axis=0, verify_integrity=False)._consolidate()
38133813

38143814
# apply the selection filters & axis orderings
38153815
wp = self.process_axes(wp, columns=columns)

‎pandas/tests/frame/test_block_internals.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ def test_cast_internals(self):
4040

4141
def test_consolidate(self):
4242
self.frame['E'] = 7.
43-
consolidated = self.frame.consolidate()
43+
consolidated = self.frame._consolidate()
4444
self.assertEqual(len(consolidated._data.blocks), 1)
4545

4646
# Ensure copy, do I want this?
47-
recons = consolidated.consolidate()
47+
recons = consolidated._consolidate()
4848
self.assertIsNot(recons, consolidated)
4949
assert_frame_equal(recons, consolidated)
5050

5151
self.frame['F'] = 8.
5252
self.assertEqual(len(self.frame._data.blocks), 3)
53-
self.frame.consolidate(inplace=True)
53+
self.frame._consolidate(inplace=True)
5454
self.assertEqual(len(self.frame._data.blocks), 1)
5555

5656
def test_consolidate_inplace(self):

‎pandas/tests/frame/test_nonunique_indexes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def check(result, expected=None):
8787
check(df, expected)
8888

8989
# consolidate
90-
df = df.consolidate()
90+
df = df._consolidate()
9191
expected = DataFrame([[1, 1, 'bah', 3], [1, 2, 'bah', 3],
9292
[2, 3, 'bah', 3]],
9393
columns=['foo', 'foo', 'string', 'foo2'])

‎pandas/tests/io/test_pytables.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def test_repr(self):
418418
df['datetime1'] = datetime.datetime(2001, 1, 2, 0, 0)
419419
df['datetime2'] = datetime.datetime(2001, 1, 3, 0, 0)
420420
df.loc[3:6, ['obj1']] = np.nan
421-
df = df.consolidate()._convert(datetime=True)
421+
df = df._consolidate()._convert(datetime=True)
422422

423423
warnings.filterwarnings('ignore', category=PerformanceWarning)
424424
store['df'] = df
@@ -762,7 +762,7 @@ def test_put_mixed_type(self):
762762
df['datetime1'] = datetime.datetime(2001, 1, 2, 0, 0)
763763
df['datetime2'] = datetime.datetime(2001, 1, 3, 0, 0)
764764
df.loc[3:6, ['obj1']] = np.nan
765-
df = df.consolidate()._convert(datetime=True)
765+
df = df._consolidate()._convert(datetime=True)
766766

767767
with ensure_clean_store(self.path) as store:
768768
_maybe_remove(store, 'df')
@@ -2077,7 +2077,7 @@ def test_table_mixed_dtypes(self):
20772077
df['datetime1'] = datetime.datetime(2001, 1, 2, 0, 0)
20782078
df['datetime2'] = datetime.datetime(2001, 1, 3, 0, 0)
20792079
df.loc[3:6, ['obj1']] = np.nan
2080-
df = df.consolidate()._convert(datetime=True)
2080+
df = df._consolidate()._convert(datetime=True)
20812081

20822082
with ensure_clean_store(self.path) as store:
20832083
store.append('df1_mixed', df)
@@ -2091,7 +2091,7 @@ def test_table_mixed_dtypes(self):
20912091
wp['bool2'] = wp['ItemB'] > 0
20922092
wp['int1'] = 1
20932093
wp['int2'] = 2
2094-
wp = wp.consolidate()
2094+
wp = wp._consolidate()
20952095

20962096
with ensure_clean_store(self.path) as store:
20972097
store.append('p1_mixed', wp)
@@ -2106,7 +2106,7 @@ def test_table_mixed_dtypes(self):
21062106
wp['bool2'] = wp['l2'] > 0
21072107
wp['int1'] = 1
21082108
wp['int2'] = 2
2109-
wp = wp.consolidate()
2109+
wp = wp._consolidate()
21102110

21112111
with ensure_clean_store(self.path) as store:
21122112
store.append('p4d_mixed', wp)
@@ -2134,7 +2134,7 @@ def test_unimplemented_dtypes_table_columns(self):
21342134
df['obj1'] = 'foo'
21352135
df['obj2'] = 'bar'
21362136
df['datetime1'] = datetime.date(2001, 1, 2)
2137-
df = df.consolidate()._convert(datetime=True)
2137+
df = df._consolidate()._convert(datetime=True)
21382138

21392139
with ensure_clean_store(self.path) as store:
21402140
# this fails because we have a date in the object block......
@@ -2949,7 +2949,7 @@ def _make_one():
29492949
df['bool2'] = df['B'] > 0
29502950
df['int1'] = 1
29512951
df['int2'] = 2
2952-
return df.consolidate()
2952+
return df._consolidate()
29532953

29542954
df1 = _make_one()
29552955
df2 = _make_one()

‎pandas/tests/test_generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def test_validate_bool_args(self):
658658
super(DataFrame, df).sort_index(inplace=value)
659659

660660
with self.assertRaises(ValueError):
661-
super(DataFrame, df).consolidate(inplace=value)
661+
super(DataFrame, df)._consolidate(inplace=value)
662662

663663
with self.assertRaises(ValueError):
664664
super(DataFrame, df).fillna(value=0, inplace=value)

‎pandas/tests/test_panel4d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def test_consolidate(self):
677677
self.panel4d['foo'] = 1.
678678
self.assertFalse(self.panel4d._data.is_consolidated())
679679

680-
panel4d = self.panel4d.consolidate()
680+
panel4d = self.panel4d._consolidate()
681681
self.assertTrue(panel4d._data.is_consolidated())
682682

683683
def test_ctor_dict(self):

‎pandas/tools/concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None,
263263
raise TypeError("cannot concatenate a non-NDFrame object")
264264

265265
# consolidate
266-
obj.consolidate(inplace=True)
266+
obj._consolidate(inplace=True)
267267
ndims.add(obj.ndim)
268268

269269
# get the sample

‎pandas/tseries/resample.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _convert_obj(self, obj):
221221
-------
222222
obj : converted object
223223
"""
224-
obj = obj.consolidate()
224+
obj = obj._consolidate()
225225
return obj
226226

227227
def _get_binner_for_time(self):

0 commit comments

Comments
 (0)
Please sign in to comment.