Skip to content

Commit 7e3212e

Browse files
committed
Merge branch '016_depr_pr' of https://github.com/jsexauer/pandas into jsexauer-016_depr_pr
Conflicts: doc/source/whatsnew/v0.16.0.txt
2 parents 8992129 + 1bc05c4 commit 7e3212e

File tree

10 files changed

+6
-132
lines changed

10 files changed

+6
-132
lines changed

doc/source/whatsnew/v0.16.0.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ Deprecations
370370

371371
.. _whatsnew_0160.deprecations:
372372

373+
- ``DataFrame.pivot_table`` and ``crosstab``'s ``rows`` and ``cols`` keyword arguments were removed in favor
374+
of ``index`` and ``columns`` (:issue:`6581`)
375+
- ``DataFrame.to_excel`` and ``DataFrame.to_csv`` ``cols`` keyword argument was removed in favor of ``columns`` (:issue:`6581`)
376+
- Removed ``convert_dummies`` in favor of ``get_dummies`` (:issue:`6581`)
377+
- Removed ``value_range`` in favor of ``describe`` (:issue:`6581`)
373378

374379
Performance
375380
~~~~~~~~~~~

pandas/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
from pandas.tools.pivot import pivot_table, crosstab
5858
from pandas.tools.plotting import scatter_matrix, plot_params
5959
from pandas.tools.tile import cut, qcut
60-
from pandas.tools.util import value_range
6160
from pandas.core.reshape import melt
6261
from pandas.util.print_versions import show_versions
6362
import pandas.util.testing

pandas/core/frame.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,6 @@ def to_panel(self):
11071107

11081108
to_wide = deprecate('to_wide', to_panel)
11091109

1110-
@deprecate_kwarg(old_arg_name='cols', new_arg_name='columns')
11111110
def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
11121111
columns=None, header=True, index=True, index_label=None,
11131112
mode='w', encoding=None, quoting=None,
@@ -1165,7 +1164,6 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
11651164
or new (expanded format) if False)
11661165
date_format : string, default None
11671166
Format string for datetime objects
1168-
cols : kwarg only alias of columns [deprecated]
11691167
"""
11701168

11711169
formatter = fmt.CSVFormatter(self, path_or_buf,
@@ -1186,7 +1184,6 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
11861184
if path_or_buf is None:
11871185
return formatter.path_or_buf.getvalue()
11881186

1189-
@deprecate_kwarg(old_arg_name='cols', new_arg_name='columns')
11901187
def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
11911188
float_format=None, columns=None, header=True, index=True,
11921189
index_label=None, startrow=0, startcol=0, engine=None,
@@ -1228,7 +1225,6 @@ def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',
12281225
encoding: string, default None
12291226
encoding of the resulting excel file. Only necessary for xlwt,
12301227
other writers support unicode natively.
1231-
cols : kwarg only alias of columns [deprecated]
12321228
inf_rep : string, default 'inf'
12331229
Representation for infinity (there is no native representation for
12341230
infinity in Excel)

pandas/core/reshape.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -929,39 +929,6 @@ def melt_stub(df, stub, i, j):
929929
newdf = newdf.merge(new, how="outer", on=id_vars + [j], copy=False)
930930
return newdf.set_index([i, j])
931931

932-
933-
def convert_dummies(data, cat_variables, prefix_sep='_'):
934-
"""
935-
Compute DataFrame with specified columns converted to dummy variables (0 /
936-
1). Result columns will be prefixed with the column name, then the level
937-
name, e.g. 'A_foo' for column A and level foo
938-
939-
Parameters
940-
----------
941-
data : DataFrame
942-
cat_variables : list-like
943-
Must be column names in the DataFrame
944-
prefix_sep : string, default '_'
945-
String to use to separate column name from dummy level
946-
947-
Returns
948-
-------
949-
dummies : DataFrame
950-
"""
951-
import warnings
952-
953-
warnings.warn("'convert_dummies' is deprecated and will be removed "
954-
"in a future release. Use 'get_dummies' instead.",
955-
FutureWarning)
956-
957-
result = data.drop(cat_variables, axis=1)
958-
for variable in cat_variables:
959-
dummies = _get_dummies_1d(data[variable], prefix=variable,
960-
prefix_sep=prefix_sep)
961-
result = result.join(dummies)
962-
return result
963-
964-
965932
def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,
966933
columns=None):
967934
"""

pandas/io/tests/test_excel.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,6 @@ def test_excel_sheet_by_name_raise(self):
556556

557557
self.assertRaises(xlrd.XLRDError, xl.parse, '0')
558558

559-
def test_excel_deprecated_options(self):
560-
with ensure_clean(self.ext) as path:
561-
with tm.assert_produces_warning(FutureWarning):
562-
self.frame.to_excel(path, 'test1', cols=['A', 'B'])
563-
564-
with tm.assert_produces_warning(False):
565-
self.frame.to_excel(path, 'test1', columns=['A', 'B'])
566-
567559
def test_excelwriter_contextmanager(self):
568560
_skip_if_no_xlrd()
569561

pandas/tests/test_frame.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5944,23 +5944,6 @@ def test_boolean_comparison(self):
59445944
self.assertRaises(ValueError, lambda : df == (2,2))
59455945
self.assertRaises(ValueError, lambda : df == [2,2])
59465946

5947-
def test_to_csv_deprecated_options(self):
5948-
5949-
pname = '__tmp_to_csv_deprecated_options__'
5950-
with ensure_clean(pname) as path:
5951-
5952-
self.tsframe[1:3] = np.nan
5953-
self.tsframe.to_csv(path, nanRep='foo')
5954-
recons = read_csv(path,index_col=0,parse_dates=[0],na_values=['foo'])
5955-
assert_frame_equal(self.tsframe, recons)
5956-
5957-
with tm.assert_produces_warning(FutureWarning):
5958-
self.frame.to_csv(path, cols=['A', 'B'])
5959-
5960-
with tm.assert_produces_warning(False):
5961-
self.frame.to_csv(path, columns=['A', 'B'])
5962-
5963-
59645947
def test_to_csv_from_csv(self):
59655948

59665949
pname = '__tmp_to_csv_from_csv__'

pandas/tests/test_reshape.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pandas.util.testing import assert_frame_equal
1717
from numpy.testing import assert_array_equal
1818

19-
from pandas.core.reshape import (melt, convert_dummies, lreshape, get_dummies,
19+
from pandas.core.reshape import (melt, lreshape, get_dummies,
2020
wide_to_long)
2121
import pandas.util.testing as tm
2222
from pandas.compat import StringIO, cPickle, range, u
@@ -322,34 +322,6 @@ def test_dataframe_dummies_with_categorical(self):
322322
'cat_x', 'cat_y']]
323323
assert_frame_equal(result, expected)
324324

325-
326-
class TestConvertDummies(tm.TestCase):
327-
def test_convert_dummies(self):
328-
df = DataFrame({'A': ['foo', 'bar', 'foo', 'bar',
329-
'foo', 'bar', 'foo', 'foo'],
330-
'B': ['one', 'one', 'two', 'three',
331-
'two', 'two', 'one', 'three'],
332-
'C': np.random.randn(8),
333-
'D': np.random.randn(8)})
334-
335-
with tm.assert_produces_warning(FutureWarning):
336-
result = convert_dummies(df, ['A', 'B'])
337-
result2 = convert_dummies(df, ['A', 'B'], prefix_sep='.')
338-
339-
expected = DataFrame({'A_foo': [1, 0, 1, 0, 1, 0, 1, 1],
340-
'A_bar': [0, 1, 0, 1, 0, 1, 0, 0],
341-
'B_one': [1, 1, 0, 0, 0, 0, 1, 0],
342-
'B_two': [0, 0, 1, 0, 1, 1, 0, 0],
343-
'B_three': [0, 0, 0, 1, 0, 0, 0, 1],
344-
'C': df['C'].values,
345-
'D': df['D'].values},
346-
columns=result.columns, dtype=float)
347-
expected2 = expected.rename(columns=lambda x: x.replace('_', '.'))
348-
349-
tm.assert_frame_equal(result, expected)
350-
tm.assert_frame_equal(result2, expected2)
351-
352-
353325
class TestLreshape(tm.TestCase):
354326

355327
def test_pairs(self):

pandas/tools/pivot.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import pandas.core.common as com
1414
import numpy as np
1515

16-
@deprecate_kwarg(old_arg_name='cols', new_arg_name='columns')
17-
@deprecate_kwarg(old_arg_name='rows', new_arg_name='index')
1816
def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean',
1917
fill_value=None, margins=False, dropna=True):
2018
"""
@@ -42,8 +40,6 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean',
4240
Add all row / columns (e.g. for subtotal / grand totals)
4341
dropna : boolean, default True
4442
Do not include columns whose entries are all NaN
45-
rows : kwarg only alias of index [deprecated]
46-
cols : kwarg only alias of columns [deprecated]
4743
4844
Examples
4945
--------
@@ -319,8 +315,6 @@ def _convert_by(by):
319315
by = list(by)
320316
return by
321317

322-
@deprecate_kwarg(old_arg_name='cols', new_arg_name='columns')
323-
@deprecate_kwarg(old_arg_name='rows', new_arg_name='index')
324318
def crosstab(index, columns, values=None, rownames=None, colnames=None,
325319
aggfunc=None, margins=False, dropna=True):
326320
"""
@@ -346,8 +340,6 @@ def crosstab(index, columns, values=None, rownames=None, colnames=None,
346340
Add row/column margins (subtotals)
347341
dropna : boolean, default True
348342
Do not include columns whose entries are all NaN
349-
rows : kwarg only alias of index [deprecated]
350-
cols : kwarg only alias of columns [deprecated]
351343
352344
Notes
353345
-----

pandas/tools/tests/test_pivot.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ def test_pivot_table(self):
5353
expected = self.data.groupby(index + [columns])['D'].agg(np.mean).unstack()
5454
tm.assert_frame_equal(table, expected)
5555

56-
def test_pivot_table_warnings(self):
57-
index = ['A', 'B']
58-
columns = 'C'
59-
with tm.assert_produces_warning(FutureWarning):
60-
table = pivot_table(self.data, values='D', rows=index,
61-
cols=columns)
62-
63-
with tm.assert_produces_warning(False):
64-
table2 = pivot_table(self.data, values='D', index=index,
65-
columns=columns)
66-
67-
tm.assert_frame_equal(table, table2)
68-
6956
def test_pivot_table_nocols(self):
7057
df = DataFrame({'rows': ['a', 'b', 'c'],
7158
'cols': ['x', 'y', 'z'],

pandas/tools/util.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,3 @@ def compose(*funcs):
4848
"""Compose 2 or more callables"""
4949
assert len(funcs) > 1, 'At least 2 callables must be passed to compose'
5050
return reduce(_compose2, funcs)
51-
52-
### FIXME: remove in 0.16
53-
def value_range(df):
54-
"""
55-
Return the minimum and maximum of a dataframe in a series object
56-
57-
Parameters
58-
----------
59-
df : DataFrame
60-
61-
Returns
62-
-------
63-
(maximum, minimum) : Series
64-
65-
"""
66-
from pandas import Series
67-
warnings.warn("value_range is deprecated. Use .describe() instead", FutureWarning)
68-
69-
return Series((min(df.min()), max(df.max())), ('Minimum', 'Maximum'))

0 commit comments

Comments
 (0)