Skip to content

Commit ad18ea3

Browse files
authored
Remove read_table deprecation (#27102)
* Undeprecate read_table * Add whatsnew note * flake8 * Edit 0.24.0 read_table deprecation to mention undeprecation, and move current 0.25
1 parent 9693230 commit ad18ea3

File tree

5 files changed

+10
-56
lines changed

5 files changed

+10
-56
lines changed

doc/source/whatsnew/v0.24.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ Deprecations
12981298
- :meth:`Series.compress` is deprecated. Use ``Series[condition]`` instead (:issue:`18262`)
12991299
- The signature of :meth:`Series.to_csv` has been uniformed to that of :meth:`DataFrame.to_csv`: the name of the first argument is now ``path_or_buf``, the order of subsequent arguments has changed, the ``header`` argument now defaults to ``True``. (:issue:`19715`)
13001300
- :meth:`Categorical.from_codes` has deprecated providing float values for the ``codes`` argument. (:issue:`21767`)
1301-
- :func:`pandas.read_table` is deprecated. Instead, use :func:`read_csv` passing ``sep='\t'`` if necessary (:issue:`21948`)
1301+
- :func:`pandas.read_table` is deprecated. Instead, use :func:`read_csv` passing ``sep='\t'`` if necessary. This deprecation has been removed in 0.25.0. (:issue:`21948`)
13021302
- :meth:`Series.str.cat` has deprecated using arbitrary list-likes *within* list-likes. A list-like container may still contain
13031303
many ``Series``, ``Index`` or 1-dimensional ``np.ndarray``, or alternatively, only scalar values. (:issue:`21950`)
13041304
- :meth:`FrozenNDArray.searchsorted` has deprecated the ``v`` parameter in favor of ``value`` (:issue:`14645`)

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ Other deprecations
604604
- The :meth:`Series.ftype`, :meth:`Series.ftypes` and :meth:`DataFrame.ftypes` methods are deprecated and will be removed in a future version.
605605
Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`).
606606
- :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`)
607+
- func:`read_table` has been undeprecated. (:issue:`25220`)
607608

608609
.. _whatsnew_0250.prior_deprecations:
609610

pandas/io/parsers.py

+2-24
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,8 @@ def _read(filepath_or_buffer: FilePathOrBuffer, kwds):
540540

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

543-
# prepare read_table deprecation
544-
if name == "read_table":
545-
sep = False
546-
else:
547-
sep = default_sep
548-
549543
def parser_f(filepath_or_buffer: FilePathOrBuffer,
550-
sep=sep,
544+
sep=default_sep,
551545
delimiter=None,
552546

553547
# Column and Index Locations and Names
@@ -613,19 +607,6 @@ def parser_f(filepath_or_buffer: FilePathOrBuffer,
613607
memory_map=False,
614608
float_precision=None):
615609

616-
# deprecate read_table GH21948
617-
if name == "read_table":
618-
if sep is False and delimiter is None:
619-
warnings.warn("read_table is deprecated, use read_csv "
620-
"instead, passing sep='\\t'.",
621-
FutureWarning, stacklevel=2)
622-
else:
623-
warnings.warn("read_table is deprecated, use read_csv "
624-
"instead.",
625-
FutureWarning, stacklevel=2)
626-
if sep is False:
627-
sep = default_sep
628-
629610
# gh-23761
630611
#
631612
# When a dialect is passed, it overrides any of the overlapping
@@ -732,10 +713,7 @@ def parser_f(filepath_or_buffer: FilePathOrBuffer,
732713
read_table = _make_parser_function('read_table', default_sep='\t')
733714
read_table = Appender(_doc_read_csv_and_table.format(
734715
func_name='read_table',
735-
summary="""Read general delimited file into DataFrame.
736-
737-
.. deprecated:: 0.24.0
738-
Use :func:`pandas.read_csv` instead, passing ``sep='\\t'`` if necessary.""",
716+
summary='Read general delimited file into DataFrame.',
739717
_default_sep=r"'\\t' (tab-stop)")
740718
)(read_table)
741719

pandas/tests/io/parser/test_common.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1917,16 +1917,14 @@ def test_read_csv_memory_growth_chunksize(all_parsers):
19171917
pass
19181918

19191919

1920-
def test_read_table_deprecated(all_parsers):
1920+
def test_read_table_equivalency_to_read_csv(all_parsers):
19211921
# see gh-21948
1922+
# As of 0.25.0, read_table is undeprecated
19221923
parser = all_parsers
19231924
data = "a\tb\n1\t2\n3\t4"
19241925
expected = parser.read_csv(StringIO(data), sep="\t")
1925-
1926-
with tm.assert_produces_warning(FutureWarning,
1927-
check_stacklevel=False):
1928-
result = parser.read_table(StringIO(data))
1929-
tm.assert_frame_equal(result, expected)
1926+
result = parser.read_table(StringIO(data))
1927+
tm.assert_frame_equal(result, expected)
19301928

19311929

19321930
def test_first_row_bom(all_parsers):

pandas/tests/io/test_common.py

+2-25
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext):
160160

161161
@pytest.mark.parametrize('reader, module, error_class, fn_ext', [
162162
(pd.read_csv, 'os', FileNotFoundError, 'csv'),
163+
(pd.read_table, 'os', FileNotFoundError, 'csv'),
163164
(pd.read_fwf, 'os', FileNotFoundError, 'txt'),
164165
(pd.read_excel, 'xlrd', FileNotFoundError, 'xlsx'),
165166
(pd.read_feather, 'feather', Exception, 'feather'),
@@ -191,18 +192,9 @@ def test_read_expands_user_home_dir(self, reader, module,
191192
msg1, msg2, msg3, msg4, msg5)):
192193
reader(path)
193194

194-
def test_read_non_existant_read_table(self):
195-
path = os.path.join(HERE, 'data', 'does_not_exist.' + 'csv')
196-
msg1 = r"File b'.+does_not_exist\.csv' does not exist"
197-
msg2 = (r"\[Errno 2\] File .+does_not_exist\.csv does not exist:"
198-
r" '.+does_not_exist\.csv'")
199-
with pytest.raises(FileNotFoundError, match=r"({}|{})".format(
200-
msg1, msg2)):
201-
with tm.assert_produces_warning(FutureWarning):
202-
pd.read_table(path)
203-
204195
@pytest.mark.parametrize('reader, module, path', [
205196
(pd.read_csv, 'os', ('io', 'data', 'iris.csv')),
197+
(pd.read_table, 'os', ('io', 'data', 'iris.csv')),
206198
(pd.read_fwf, 'os', ('io', 'data', 'fixed_width_format.txt')),
207199
(pd.read_excel, 'xlrd', ('io', 'data', 'test1.xlsx')),
208200
(pd.read_feather, 'feather', ('io', 'data', 'feather-0_3_1.feather')),
@@ -228,21 +220,6 @@ def test_read_fspath_all(self, reader, module, path, datapath):
228220
else:
229221
tm.assert_frame_equal(result, expected)
230222

231-
def test_read_fspath_all_read_table(self, datapath):
232-
path = datapath('io', 'data', 'iris.csv')
233-
234-
mypath = CustomFSPath(path)
235-
with tm.assert_produces_warning(FutureWarning):
236-
result = pd.read_table(mypath)
237-
with tm.assert_produces_warning(FutureWarning):
238-
expected = pd.read_table(path)
239-
240-
if path.endswith('.pickle'):
241-
# categorical
242-
tm.assert_categorical_equal(result, expected)
243-
else:
244-
tm.assert_frame_equal(result, expected)
245-
246223
@pytest.mark.parametrize('writer_name, writer_kwargs, module', [
247224
('to_csv', {}, 'os'),
248225
('to_excel', {'engine': 'xlwt'}, 'xlwt'),

0 commit comments

Comments
 (0)