Skip to content

Commit f6c1c94

Browse files
committed
changes based on comments on PR
1 parent d97418c commit f6c1c94

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ I/O
618618
- Bug in :meth:`read_csv` causing segmentation fault when ``encoding_errors`` is not a string. (:issue:`59059`)
619619
- Bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)
620620
- Bug in :meth:`read_csv` raising ``TypeError`` when ``nrows`` and ``iterator`` are specified without specifying a ``chunksize``. (:issue:`59079`)
621+
- Bug in :meth:`read_csv` where the order of the ``na_values`` makes an inconsistency when ``na_values`` is a list non-string values. (:issue:`59303`)
621622
- Bug in :meth:`read_excel` raising ``ValueError`` when passing array of boolean values when ``dtype="boolean"``. (:issue:`58159`)
622623
- Bug in :meth:`read_json` not validating the ``typ`` argument to not be exactly ``"frame"`` or ``"series"`` (:issue:`59124`)
623624
- Bug in :meth:`read_stata` raising ``KeyError`` when input file is stored in big-endian format and contains strL data. (:issue:`58638`)
@@ -693,7 +694,6 @@ Other
693694
- Bug in :meth:`Series.dt` methods in :class:`ArrowDtype` that were returning incorrect values. (:issue:`57355`)
694695
- Bug in :meth:`Series.rank` that doesn't preserve missing values for nullable integers when ``na_option='keep'``. (:issue:`56976`)
695696
- Bug in :meth:`Series.replace` and :meth:`DataFrame.replace` inconsistently replacing matching instances when ``regex=True`` and missing values are present. (:issue:`56599`)
696-
- Bug in :meth:`_clean_na_values` in :class:`TextFileReader` that was not properly handling ``na_values`` when it is a list of strings. (:issue:`59303`)
697697
- Bug in Dataframe Interchange Protocol implementation was returning incorrect results for data buffers' associated dtype, for string and datetime columns (:issue:`54781`)
698698
- Bug in ``Series.list`` methods not preserving the original :class:`Index`. (:issue:`58425`)
699699

pandas/tests/io/parser/test_na_values.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -815,20 +815,21 @@ def test_bool_and_nan_to_float(all_parsers):
815815

816816

817817
@xfail_pyarrow
818-
def test_na_values_dict_without_dtype(all_parsers):
819-
# GH#59303
818+
@pytest.mark.parametrize(
819+
"na_values, expected_result, test_id",
820+
[
821+
({"A": [-99.0, -99]}, DataFrame({"A": [np.nan, np.nan, np.nan, np.nan]}), "float_first"),
822+
({"A": [-99, -99.0]}, DataFrame({"A": [np.nan, np.nan, np.nan, np.nan]}), "int_first"),
823+
],
824+
ids=["float_first", "int_first"]
825+
)
826+
def test_na_values_dict_without_dtype(all_parsers, na_values, expected_result, test_id):
820827
parser = all_parsers
821828
data = """A
822829
-99
823830
-99
824831
-99.0
825832
-99.0"""
826-
# this would FAIL BEFORE this fix
827-
result_1 = parser.read_csv(StringIO(data), na_values={"A": [-99.0, -99]})
828-
expected_1 = DataFrame.from_dict({"A": [np.nan, np.nan, np.nan, np.nan]})
829-
tm.assert_frame_equal(result_1, expected_1)
830-
831-
# this would PASS even BEFORE this fix
832-
result_2 = parser.read_csv(StringIO(data), na_values={"A": [-99, -99.0]})
833-
expected_2 = DataFrame.from_dict({"A": [np.nan, np.nan, np.nan, np.nan]})
834-
tm.assert_frame_equal(result_2, expected_2)
833+
834+
result = parser.read_csv(StringIO(data), na_values=na_values)
835+
tm.assert_frame_equal(result, expected_result)

0 commit comments

Comments
 (0)