diff --git a/pandas/_libs/parsers.pyx b/pandas/_libs/parsers.pyx index a11bf370412d2..a6ffa685054fa 100644 --- a/pandas/_libs/parsers.pyx +++ b/pandas/_libs/parsers.pyx @@ -1924,7 +1924,7 @@ def _concatenate_chunks(list chunks): if warning_columns: warning_names = ','.join(warning_columns) warning_message = " ".join([ - f"Columns ({warning_names}) have mixed types." + f"Columns ({warning_names}) have mixed types.", f"Specify dtype option on import or set low_memory=False." ]) warnings.warn(warning_message, DtypeWarning, stacklevel=8) diff --git a/pandas/tests/io/parser/common/test_chunksize.py b/pandas/tests/io/parser/common/test_chunksize.py index 6d5aeaa713687..303174d9dbd1a 100644 --- a/pandas/tests/io/parser/common/test_chunksize.py +++ b/pandas/tests/io/parser/common/test_chunksize.py @@ -6,6 +6,7 @@ import numpy as np import pytest +import regex as re from pandas.errors import DtypeWarning @@ -190,7 +191,11 @@ def test_warn_if_chunks_have_mismatched_type(all_parsers, request): buf = StringIO(data) try: - with tm.assert_produces_warning(warning_type): + msg = ( + "Columns (0) have mixed types. Specify dtype option on import or " + "set low_memory=False." + ) + with tm.assert_produces_warning(warning_type, match=re.escape(msg)): df = parser.read_csv(buf) except AssertionError as err: # 2021-02-21 this occasionally fails on the CI with an unexpected