You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Went through #18262 looking for an easy task, and deprecating read_table looked like one. Currently, there's a function factory _make_parser_function which produces both read_csv and read_tablehere:
Seems to me the simplest solution is wrapping read_table like this:
defdepr_read_table(func):
"""Deprecates read_table."""fromfunctoolsimportwraps@wraps(read_table)defdepr_func(*args, **kwargs):
iflen(args) >1or"sep"inkwargsor"delimiter"inkwargs:
warnings.warn("read_table is deprecated, use read_csv instead",
FutureWarning, stacklevel=2)
else:
warnings.warn("read_table is deprecated, use read_csv with ""sep='\\t' instead",
FutureWarning, stacklevel=2)
returnfunc(*args, **kwargs)
returndepr_funcread_table=depr_read_table(read_table)
I would have to find out how to change the docs to declare the function deprecated, but I suppose that is easy...?
Result:
In [1]: import pandas as pd
In [2]: df = pd.DataFrame({"a": [1], "b": [2]})
In [3]: df.to_csv("test.csv", sep="\t")
In [4]: pd.read_table("test.csv", index_col=0)
/home/dahlbaek/virtualenvs/pandas-dev/bin/ipython:1: FutureWarning: read_table is deprecated, use read_csv with sep='\t' instead
#!/home/dahlbaek/virtualenvs/pandas-dev/bin/python
Out[4]:
a b
0 1 2
In [5]: pd.read_table("test.csv", "\t", index_col=0)
/home/dahlbaek/virtualenvs/pandas-dev/bin/ipython:1: FutureWarning: read_table is deprecated, use read_csv instead
#!/home/dahlbaek/virtualenvs/pandas-dev/bin/python
Out[5]:
a b
0 1 2
In [6]: pd.read_table("test.csv", sep="\t", index_col=0)
/home/dahlbaek/virtualenvs/pandas-dev/bin/ipython:1: FutureWarning: read_table is deprecated, use read_csv instead
#!/home/dahlbaek/virtualenvs/pandas-dev/bin/python
Out[6]:
a b
0 1 2
In [7]: pd.read_table("test.csv", delimiter="\t", index_col=0)
/home/dahlbaek/virtualenvs/pandas-dev/bin/ipython:1: FutureWarning: read_table is deprecated, use read_csv instead
#!/home/dahlbaek/virtualenvs/pandas-dev/bin/python
Out[7]:
a b
0 1 2
In [8]: df
Out[8]:
a b
0 1 2
Any thoughts?
The text was updated successfully, but these errors were encountered:
I suppose declaring the function deprecated could be as simple as changing _read_table_dochere into
_read_table_doc=""".. deprecated:: 0.24.0 Use :func:`pandas.read_csv` instead, passing `sep='\t'` if necessary.Read general delimited file into DataFrame%s"""% (_parser_params% (_sep_doc.format(default="\\t (tab-stop)"),
_engine_doc))```
I would consider adding another parameter to _make_parser_function so that it adds the appropriate deprecation messages both in the code and in the docstring.
Went through #18262 looking for an easy task, and deprecating
read_table
looked like one. Currently, there's a function factory_make_parser_function
which produces bothread_csv
andread_table
here:Seems to me the simplest solution is wrapping
read_table
like this:I would have to find out how to change the docs to declare the function deprecated, but I suppose that is easy...?
Result:
Any thoughts?
The text was updated successfully, but these errors were encountered: