Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Undeprecate read_table
  • Loading branch information
Matt Roeschke committed Jun 28, 2019
commit 8b74efa1e54033b060c57f83246594d3a68cb987
26 changes: 2 additions & 24 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,8 @@ def _read(filepath_or_buffer: FilePathOrBuffer, kwds):

def _make_parser_function(name, default_sep=','):

# prepare read_table deprecation
if name == "read_table":
sep = False
else:
sep = default_sep

def parser_f(filepath_or_buffer: FilePathOrBuffer,
sep=sep,
sep=default_sep,
delimiter=None,

# Column and Index Locations and Names
Expand Down Expand Up @@ -613,19 +607,6 @@ def parser_f(filepath_or_buffer: FilePathOrBuffer,
memory_map=False,
float_precision=None):

# deprecate read_table GH21948
if name == "read_table":
if sep is False and delimiter is None:
warnings.warn("read_table is deprecated, use read_csv "
"instead, passing sep='\\t'.",
FutureWarning, stacklevel=2)
else:
warnings.warn("read_table is deprecated, use read_csv "
"instead.",
FutureWarning, stacklevel=2)
if sep is False:
sep = default_sep

# gh-23761
#
# When a dialect is passed, it overrides any of the overlapping
Expand Down Expand Up @@ -732,10 +713,7 @@ def parser_f(filepath_or_buffer: FilePathOrBuffer,
read_table = _make_parser_function('read_table', default_sep='\t')
read_table = Appender(_doc_read_csv_and_table.format(
func_name='read_table',
summary="""Read general delimited file into DataFrame.

.. deprecated:: 0.24.0
Use :func:`pandas.read_csv` instead, passing ``sep='\\t'`` if necessary.""",
summary="""Read general delimited file into DataFrame.""",
_default_sep=r"'\\t' (tab-stop)")
)(read_table)

Expand Down
27 changes: 2 additions & 25 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext):

@pytest.mark.parametrize('reader, module, error_class, fn_ext', [
(pd.read_csv, 'os', FileNotFoundError, 'csv'),
(pd.read_table, 'os', FileNotFoundError, 'csv'),
(pd.read_fwf, 'os', FileNotFoundError, 'txt'),
(pd.read_excel, 'xlrd', FileNotFoundError, 'xlsx'),
(pd.read_feather, 'feather', Exception, 'feather'),
Expand Down Expand Up @@ -191,18 +192,9 @@ def test_read_expands_user_home_dir(self, reader, module,
msg1, msg2, msg3, msg4, msg5)):
reader(path)

def test_read_non_existant_read_table(self):
path = os.path.join(HERE, 'data', 'does_not_exist.' + 'csv')
msg1 = r"File b'.+does_not_exist\.csv' does not exist"
msg2 = (r"\[Errno 2\] File .+does_not_exist\.csv does not exist:"
r" '.+does_not_exist\.csv'")
with pytest.raises(FileNotFoundError, match=r"({}|{})".format(
msg1, msg2)):
with tm.assert_produces_warning(FutureWarning):
pd.read_table(path)

@pytest.mark.parametrize('reader, module, path', [
(pd.read_csv, 'os', ('io', 'data', 'iris.csv')),
(pd.read_table, 'os', ('io', 'data', 'iris.csv')),
(pd.read_fwf, 'os', ('io', 'data', 'fixed_width_format.txt')),
(pd.read_excel, 'xlrd', ('io', 'data', 'test1.xlsx')),
(pd.read_feather, 'feather', ('io', 'data', 'feather-0_3_1.feather')),
Expand All @@ -228,21 +220,6 @@ def test_read_fspath_all(self, reader, module, path, datapath):
else:
tm.assert_frame_equal(result, expected)

def test_read_fspath_all_read_table(self, datapath):
path = datapath('io', 'data', 'iris.csv')

mypath = CustomFSPath(path)
with tm.assert_produces_warning(FutureWarning):
result = pd.read_table(mypath)
with tm.assert_produces_warning(FutureWarning):
expected = pd.read_table(path)

if path.endswith('.pickle'):
# categorical
tm.assert_categorical_equal(result, expected)
else:
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize('writer_name, writer_kwargs, module', [
('to_csv', {}, 'os'),
('to_excel', {'engine': 'xlwt'}, 'xlwt'),
Expand Down