Repository: pandas-dev/pandas (Python)

Issue:
BUG: parse_dates=False while passing date_parser tries to use date parser
### 

- [X] I have checked that this issue has not already been reported.

- [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas.

- [X] I have confirmed this bug exists on the master branch of pandas.


### Reproducible Example

```python
with open('tmp.csv', 'w+') as handle:
    handle.write('a;b;c\n0;0,00;0')

def parser(p):
    raise ValueError("Tried to use parser")

pd.read_csv('tmp.csv', date_parser=parser, parse_dates=False)
```


### Issue Description

Date parser gets run even when `parse_dates` is set to False. This happens because Line 510 in readers.py ([link](https://github.com/pandas-dev/pandas/blob/master/pandas/io/parsers/readers.py#L510) only checks whether `parse_dates`  is a bool rather than the value.
I've not been able to reproduce without the comma and semicolons in there. 

### Expected Behavior

Getting the same result as `pd.read_csv('tmp.csv')` which is a malformed DataFrame.

### Installed Versions

<details>

INSTALLED VERSIONS
------------------
commit           : 2cb96529396d93b46abab7bbc73a208e708c642e
python           : 3.8.10.final.0
python-bits      : 64
OS               : Windows
OS-release       : 10
Version          : 10.0.18363
machine          : AMD64
processor        : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder        : little
LC_ALL           : None
LANG             : None
LOCALE           : English_United Kingdom.1252
pandas           : 1.2.4
numpy            : 1.20.2
pytz             : 2021.1
dateutil         : 2.8.1
pip              : 21.1.1
setuptools       : 52.0.0.post20210125
Cython           : None
pytest           : 6.2.4
hypothesis       : 6.14.1
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : None
IPython          : None
pandas_datareader: None
bs4              : None
bottleneck       : None
fsspec           : None
fastparquet      : None
gcsfs            : None
matplotlib       : None
numexpr          : None
odfpy            : None
openpyxl         : 3.0.7
pandas_gbq       : None
pyarrow          : None
pyxlsb           : 1.0.8
s3fs             : None
scipy            : None
sqlalchemy       : 1.4.22
tables           : None
tabulate         : None
xarray           : None
xlrd             : 2.0.1
xlwt             : None
numba            : None

</details>



Discussion:

Patch:
diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst
index 7270227e113da..b7a9e930cd642 100644
--- a/doc/source/whatsnew/v1.4.0.rst
+++ b/doc/source/whatsnew/v1.4.0.rst
@@ -653,6 +653,7 @@ I/O
 - Bug in :func:`read_csv` raising ``ValueError`` when ``parse_dates`` was used with ``MultiIndex`` columns (:issue:`8991`)
 - Bug in :func:`read_csv` raising ``AttributeError`` when attempting to read a .csv file and infer index column dtype from an nullable integer type (:issue:`44079`)
 - :meth:`DataFrame.to_csv` and :meth:`Series.to_csv` with ``compression`` set to ``'zip'`` no longer create a zip file containing a file ending with ".zip". Instead, they try to infer the inner file name more smartly. (:issue:`39465`)
+- Bug in :func:`read_csv` when passing simultaneously a parser in ``date_parser`` and ``parse_dates=False``, the parsing was still called (:issue:`44366`)
 
 Period
 ^^^^^^
diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py
index 9f555d77948a7..2ca9be3ec097a 100644
--- a/pandas/io/parsers/readers.py
+++ b/pandas/io/parsers/readers.py
@@ -510,9 +510,15 @@ def _read(
     filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds
 ):
     """Generic reader of line files."""
-    if kwds.get("date_parser", None) is not None:
-        if isinstance(kwds["parse_dates"], bool):
-            kwds["parse_dates"] = True
+    # if we pass a date_parser and parse_dates=False, we should not parse the
+    # dates GH#44366
+    if (
+        kwds.get("date_parser", None) is not None
+        and kwds.get("parse_dates", None) is None
+    ):
+        kwds["parse_dates"] = True
+    elif kwds.get("parse_dates", None) is None:
+        kwds["parse_dates"] = False
 
     # Extract some of the arguments (pass chunksize on).
     iterator = kwds.get("iterator", False)
@@ -585,7 +591,7 @@ def read_csv(
     verbose=False,
     skip_blank_lines=True,
     # Datetime Handling
-    parse_dates=False,
+    parse_dates=None,
     infer_datetime_format=False,
     keep_date_col=False,
     date_parser=None,


Test patch:
diff --git a/pandas/tests/io/parser/test_parse_dates.py b/pandas/tests/io/parser/test_parse_dates.py
index 470440290016d..10d260bad215e 100644
--- a/pandas/tests/io/parser/test_parse_dates.py
+++ b/pandas/tests/io/parser/test_parse_dates.py
@@ -97,6 +97,39 @@ def __custom_date_parser(time):
     tm.assert_frame_equal(result, expected)
 
 
+@xfail_pyarrow
+def test_read_csv_with_custom_date_parser_parse_dates_false(all_parsers):
+    # GH44366
+    def __custom_date_parser(time):
+        time = time.astype(np.float_)
+        time = time.astype(np.int_)  # convert float seconds to int type
+        return pd.to_timedelta(time, unit="s")
+
+    testdata = StringIO(
+        """time e
+        41047.00 -93.77
+        41048.00 -95.79
+        41049.00 -98.73
+        41050.00 -93.99
+        41051.00 -97.72
+        """
+    )
+    result = all_parsers.read_csv(
+        testdata,
+        delim_whitespace=True,
+        parse_dates=False,
+        date_parser=__custom_date_parser,
+        index_col="time",
+    )
+    time = Series([41047.00, 41048.00, 41049.00, 41050.00, 41051.00], name="time")
+    expected = DataFrame(
+        {"e": [-93.77, -95.79, -98.73, -93.99, -97.72]},
+        index=time,
+    )
+
+    tm.assert_frame_equal(result, expected)
+
+
 @xfail_pyarrow
 def test_separator_date_conflict(all_parsers):
     # Regression test for gh-4678