Skip to content

Commit

Permalink
Adding deprecation logic, updating unit tests, updating documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmhowe425 committed Feb 18, 2024
1 parent 1d5423b commit e5dda99
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 603 deletions.
45 changes: 2 additions & 43 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ sep : str, defaults to ``','`` for :func:`read_csv`, ``\t`` for :func:`read_tabl
delimiters are prone to ignoring quoted data. Regex example: ``'\\r\\t'``.
delimiter : str, default ``None``
Alternative argument name for sep.
delim_whitespace : boolean, default False
Specifies whether or not whitespace (e.g. ``' '`` or ``'\t'``)
will be used as the delimiter. Equivalent to setting ``sep='\s+'``.
If this option is set to ``True``, nothing should be passed in for the
``delimiter`` parameter.

.. deprecated: 2.2.0
Use ``sep="\\s+" instead.

Column and index locations and names
++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -237,28 +229,6 @@ na_values : scalar, str, list-like, or dict, default ``None``
Additional strings to recognize as NA/NaN. If dict passed, specific per-column
NA values. See :ref:`na values const <io.navaluesconst>` below
for a list of the values interpreted as NaN by default.

keep_default_na : boolean, default ``True``
Whether or not to include the default NaN values when parsing the data.
Depending on whether ``na_values`` is passed in, the behavior is as follows:

* If ``keep_default_na`` is ``True``, and ``na_values`` are specified, ``na_values``
is appended to the default NaN values used for parsing.
* If ``keep_default_na`` is ``True``, and ``na_values`` are not specified, only
the default NaN values are used for parsing.
* If ``keep_default_na`` is ``False``, and ``na_values`` are specified, only
the NaN values specified ``na_values`` are used for parsing.
* If ``keep_default_na`` is ``False``, and ``na_values`` are not specified, no
strings will be parsed as NaN.

Note that if ``na_filter`` is passed in as ``False``, the ``keep_default_na`` and
``na_values`` parameters will be ignored.
na_filter : boolean, default ``True``
Detect missing value markers (empty strings and the value of na_values). In
data without any NAs, passing ``na_filter=False`` can improve the performance
of reading a large file.
verbose : boolean, default ``False``
Indicate number of NA values placed in non-numeric columns.
skip_blank_lines : boolean, default ``True``
If ``True``, skip over blank lines rather than interpreting as NaN values.

Expand Down Expand Up @@ -307,10 +277,6 @@ date_format : str or dict of column -> format, default ``None``
.. versionadded:: 2.0.0
dayfirst : boolean, default ``False``
DD/MM format dates, international and European format.
cache_dates : boolean, default True
If True, use a cache of unique, converted dates to apply the datetime
conversion. May produce significant speed-up when parsing duplicate
date strings, especially ones with timezone offsets.

Iteration
+++++++++
Expand Down Expand Up @@ -1144,8 +1110,6 @@ number (a ``float``, like ``5.0`` or an ``integer`` like ``5``), the
corresponding equivalent values will also imply a missing value (in this case
effectively ``[5.0, 5]`` are recognized as ``NaN``).

To completely override the default values that are recognized as missing, specify ``keep_default_na=False``.

.. _io.navaluesconst:

The default ``NaN`` recognized values are ``['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A N/A', '#N/A', 'N/A',
Expand All @@ -1163,13 +1127,13 @@ addition to the defaults. A string will first be interpreted as a numerical

.. code-block:: python
pd.read_csv("path_to_file.csv", keep_default_na=False, na_values=[""])
pd.read_csv("path_to_file.csv", na_values=[""])
Above, only an empty field will be recognized as ``NaN``.

.. code-block:: python
pd.read_csv("path_to_file.csv", keep_default_na=False, na_values=["NA", "0"])
pd.read_csv("path_to_file.csv", na_values=["NA", "0"])
Above, both ``NA`` and ``0`` as strings are ``NaN``.

Expand Down Expand Up @@ -2616,11 +2580,6 @@ Specify values that should be converted to NaN:
dfs = pd.read_html(url, na_values=["No Acquirer"])
Specify whether to keep the default set of NaN values:

.. code-block:: python
dfs = pd.read_html(url, keep_default_na=False)
Specify converters for columns. This is useful for numerical text data that has
leading zeros. By default columns that are numerical are cast to numeric
Expand Down
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ missing indicator, ``np.nan``. (:issue:`20377`)
.. code-block:: ipython
In [5]: data = 'a,b,c\n1,,3\n4,5,6'
In [6]: df = pd.read_csv(StringIO(data), engine='python', dtype=str, na_filter=True)
In [6]: df = pd.read_csv(StringIO(data), engine='python', dtype=str)
In [7]: df.loc[0, 'b']
Out[7]:
'nan'
Expand All @@ -585,7 +585,7 @@ missing indicator, ``np.nan``. (:issue:`20377`)
.. ipython:: python
data = 'a,b,c\n1,,3\n4,5,6'
df = pd.read_csv(StringIO(data), engine='python', dtype=str, na_filter=True)
df = pd.read_csv(StringIO(data), engine='python', dtype=str)
df.loc[0, 'b']
Notice how we now instead output ``np.nan`` itself instead of a stringified form of it.
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Deprecations
~~~~~~~~~~~~
- Deprecated :meth:`Timestamp.utcfromtimestamp`, use ``Timestamp.fromtimestamp(ts, "UTC")`` instead (:issue:`56680`)
- Deprecated :meth:`Timestamp.utcnow`, use ``Timestamp.now("UTC")`` instead (:issue:`56680`)
- Deprecated allowing keyword arguments ``delim_whitespace``, ``cache_dates``, ``verbose``, ``na_filter``, ``keep_default_na`` :func:`read_csv` (:issue:`55569`)
- Deprecated allowing non-keyword arguments in :meth:`Series.to_string` except ``buf``. (:issue:`57280`)
-

Expand Down

0 comments on commit e5dda99

Please sign in to comment.