Skip to content

Commit b68a518

Browse files
DEPR: deprecate DataFrame.from_csv (GH4191)
1 parent d03a22f commit b68a518

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

doc/source/api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ Serialization / IO / Conversion
938938
.. autosummary::
939939
:toctree: generated/
940940

941-
DataFrame.from_csv
942941
DataFrame.from_dict
943942
DataFrame.from_items
944943
DataFrame.from_records

doc/source/whatsnew/v0.17.0.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ Other API Changes
4343
Deprecations
4444
^^^^^^^^^^^^
4545

46+
- :meth:`DataFrame.from_csv` is deprecated. Please use :func:`pandas.read_csv`
47+
instead. This function only differs from the method in some defaults:
48+
49+
- `index_col` is ``None`` instead of ``0`` (first column)
50+
- `parse_dates` is ``False`` instead of ``True`` (parsing the index)
51+
52+
So a ``pd.DataFrame.from_csv(path)`` can be replaced by
53+
``pd.read_csv(path, index_col=0, parse_dates=True)``.
54+
55+
4656
.. _whatsnew_0170.prior_deprecations:
4757

4858
Removal of prior version deprecations/changes

pandas/core/frame.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,18 @@ def from_csv(cls, path, header=0, sep=',', index_col=0,
998998
parse_dates=True, encoding=None, tupleize_cols=False,
999999
infer_datetime_format=False):
10001000
"""
1001-
Read delimited file into DataFrame
1001+
DEPRECATED. Please use :func:`pandas.read_csv` instead.
1002+
1003+
The preferred :func:`pandas.read_csv` only differs from this method
1004+
in some defaults:
1005+
1006+
- `index_col` is ``None`` instead of ``0`` (first column)
1007+
- `parse_dates` is ``False`` instead of ``True`` (parsing the index)
1008+
1009+
So a ``pd.DataFrame.from_csv(path)`` can be replaced by
1010+
``pd.read_csv(path, index_col=0, parse_dates=True)``.
1011+
1012+
Read delimited file into DataFrame.
10021013
10031014
Parameters
10041015
----------
@@ -1020,16 +1031,17 @@ def from_csv(cls, path, header=0, sep=',', index_col=0,
10201031
datetime format based on the first datetime string. If the format
10211032
can be inferred, there often will be a large parsing speed-up.
10221033
1023-
Notes
1024-
-----
1025-
Preferable to use read_table for most general purposes but from_csv
1026-
makes for an easy roundtrip to and from file, especially with a
1027-
DataFrame of time series data
1034+
See also
1035+
--------
1036+
pandas.read_csv
10281037
10291038
Returns
10301039
-------
10311040
y : DataFrame
10321041
"""
1042+
warnings.warn("'DataFrame.from_csv' is deprecated. Use 'pandas.read_csv'"
1043+
" instead (only the defaults for the 'index_col'"
1044+
" and 'parse_dates' arguments differ).", FutureWarning)
10331045
from pandas.io.parsers import read_table
10341046
return read_table(path, header=header, sep=sep,
10351047
parse_dates=parse_dates, index_col=index_col,

0 commit comments

Comments
 (0)