Skip to content

Commit eddd8e3

Browse files
authored
CLN: Enforce verbose parameter deprecation in read_csv/read_table (#57966)
1 parent a93fd6e commit eddd8e3

File tree

6 files changed

+2
-144
lines changed

6 files changed

+2
-144
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ Removal of prior version deprecations/changes
256256
- Removed unused arguments ``*args`` and ``**kwargs`` in :class:`Resampler` methods (:issue:`50977`)
257257
- Unrecognized timezones when parsing strings to datetimes now raises a ``ValueError`` (:issue:`51477`)
258258
- Removed the :class:`Grouper` attributes ``ax``, ``groups``, ``indexer``, and ``obj`` (:issue:`51206`, :issue:`51182`)
259+
- Removed deprecated keyword ``verbose`` on :func:`read_csv` and :func:`read_table` (:issue:`56556`)
259260
- Removed the attribute ``dtypes`` from :class:`.DataFrameGroupBy` (:issue:`51997`)
260261

261262
.. ---------------------------------------------------------------------------

pandas/_libs/parsers.pyx

+1-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ from csv import (
66
QUOTE_NONE,
77
QUOTE_NONNUMERIC,
88
)
9-
import time
109
import warnings
1110

1211
from pandas.util._exceptions import find_stack_level
@@ -344,10 +343,9 @@ cdef class TextReader:
344343
object true_values, false_values
345344
object handle
346345
object orig_header
347-
bint na_filter, keep_default_na, verbose, has_usecols, has_mi_columns
346+
bint na_filter, keep_default_na, has_usecols, has_mi_columns
348347
bint allow_leading_cols
349348
uint64_t parser_start # this is modified after __init__
350-
list clocks
351349
const char *encoding_errors
352350
kh_str_starts_t *false_set
353351
kh_str_starts_t *true_set
@@ -400,7 +398,6 @@ cdef class TextReader:
400398
bint allow_leading_cols=True,
401399
skiprows=None,
402400
skipfooter=0, # int64_t
403-
bint verbose=False,
404401
float_precision=None,
405402
bint skip_blank_lines=True,
406403
encoding_errors=b"strict",
@@ -417,9 +414,6 @@ cdef class TextReader:
417414
self.parser = parser_new()
418415
self.parser.chunksize = tokenize_chunksize
419416

420-
# For timekeeping
421-
self.clocks = []
422-
423417
self.parser.usecols = (usecols is not None)
424418

425419
self._setup_parser_source(source)
@@ -507,8 +501,6 @@ cdef class TextReader:
507501
self.converters = converters
508502
self.na_filter = na_filter
509503

510-
self.verbose = verbose
511-
512504
if float_precision == "round_trip":
513505
# see gh-15140
514506
self.parser.double_converter = round_trip_wrapper
@@ -896,8 +888,6 @@ cdef class TextReader:
896888
int64_t buffered_lines
897889
int64_t irows
898890

899-
self._start_clock()
900-
901891
if rows is not None:
902892
irows = rows
903893
buffered_lines = self.parser.lines - self.parser_start
@@ -915,12 +905,8 @@ cdef class TextReader:
915905

916906
if self.parser_start >= self.parser.lines:
917907
raise StopIteration
918-
self._end_clock("Tokenization")
919908

920-
self._start_clock()
921909
columns = self._convert_column_data(rows)
922-
self._end_clock("Type conversion")
923-
self._start_clock()
924910
if len(columns) > 0:
925911
rows_read = len(list(columns.values())[0])
926912
# trim
@@ -929,18 +915,8 @@ cdef class TextReader:
929915
parser_trim_buffers(self.parser)
930916
self.parser_start -= rows_read
931917

932-
self._end_clock("Parser memory cleanup")
933-
934918
return columns
935919

936-
cdef _start_clock(self):
937-
self.clocks.append(time.time())
938-
939-
cdef _end_clock(self, str what):
940-
if self.verbose:
941-
elapsed = time.time() - self.clocks.pop(-1)
942-
print(f"{what} took: {elapsed * 1000:.2f} ms")
943-
944920
def set_noconvert(self, i: int) -> None:
945921
self.noconvert.add(i)
946922

pandas/io/parsers/base_parser.py

-4
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ def _convert_to_ndarrays(
519519
dct: Mapping,
520520
na_values,
521521
na_fvalues,
522-
verbose: bool = False,
523522
converters=None,
524523
dtypes=None,
525524
) -> dict[Any, np.ndarray]:
@@ -596,8 +595,6 @@ def _convert_to_ndarrays(
596595
cvals = self._cast_types(cvals, cast_type, c)
597596

598597
result[c] = cvals
599-
if verbose and na_count:
600-
print(f"Filled {na_count} NA values in column {c!s}")
601598
return result
602599

603600
@final
@@ -1236,7 +1233,6 @@ def converter(*date_cols, col: Hashable):
12361233
"usecols": None,
12371234
# 'iterator': False,
12381235
"chunksize": None,
1239-
"verbose": False,
12401236
"encoding": None,
12411237
"compression": None,
12421238
"skip_blank_lines": True,

pandas/io/parsers/python_parser.py

-3
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ def __init__(self, f: ReadCsvBuffer[str] | list, **kwds) -> None:
110110
if "has_index_names" in kwds:
111111
self.has_index_names = kwds["has_index_names"]
112112

113-
self.verbose = kwds["verbose"]
114-
115113
self.thousands = kwds["thousands"]
116114
self.decimal = kwds["decimal"]
117115

@@ -372,7 +370,6 @@ def _convert_data(
372370
data,
373371
clean_na_values,
374372
clean_na_fvalues,
375-
self.verbose,
376373
clean_conv,
377374
clean_dtypes,
378375
)

pandas/io/parsers/readers.py

-30
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
116116
)
117117
keep_default_na: bool
118118
na_filter: bool
119-
verbose: bool | lib.NoDefault
120119
skip_blank_lines: bool
121120
parse_dates: bool | Sequence[Hashable] | None
122121
infer_datetime_format: bool | lib.NoDefault
@@ -295,10 +294,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
295294
Detect missing value markers (empty strings and the value of ``na_values``). In
296295
data without any ``NA`` values, passing ``na_filter=False`` can improve the
297296
performance of reading a large file.
298-
verbose : bool, default False
299-
Indicate number of ``NA`` values placed in non-numeric columns.
300-
301-
.. deprecated:: 2.2.0
302297
skip_blank_lines : bool, default True
303298
If ``True``, skip over blank lines rather than interpreting as ``NaN`` values.
304299
parse_dates : bool, None, list of Hashable, list of lists or dict of {{Hashable : \
@@ -556,7 +551,6 @@ class _Fwf_Defaults(TypedDict):
556551
"converters",
557552
"iterator",
558553
"dayfirst",
559-
"verbose",
560554
"skipinitialspace",
561555
"low_memory",
562556
}
@@ -755,7 +749,6 @@ def read_csv(
755749
| None = None,
756750
keep_default_na: bool = True,
757751
na_filter: bool = True,
758-
verbose: bool | lib.NoDefault = lib.no_default,
759752
skip_blank_lines: bool = True,
760753
# Datetime Handling
761754
parse_dates: bool | Sequence[Hashable] | None = None,
@@ -845,17 +838,6 @@ def read_csv(
845838
else:
846839
delim_whitespace = False
847840

848-
if verbose is not lib.no_default:
849-
# GH#55569
850-
warnings.warn(
851-
"The 'verbose' keyword in pd.read_csv is deprecated and "
852-
"will be removed in a future version.",
853-
FutureWarning,
854-
stacklevel=find_stack_level(),
855-
)
856-
else:
857-
verbose = False
858-
859841
# locals() should never be modified
860842
kwds = locals().copy()
861843
del kwds["filepath_or_buffer"]
@@ -958,7 +940,6 @@ def read_table(
958940
| None = None,
959941
keep_default_na: bool = True,
960942
na_filter: bool = True,
961-
verbose: bool | lib.NoDefault = lib.no_default,
962943
skip_blank_lines: bool = True,
963944
# Datetime Handling
964945
parse_dates: bool | Sequence[Hashable] | None = None,
@@ -1039,17 +1020,6 @@ def read_table(
10391020
else:
10401021
delim_whitespace = False
10411022

1042-
if verbose is not lib.no_default:
1043-
# GH#55569
1044-
warnings.warn(
1045-
"The 'verbose' keyword in pd.read_table is deprecated and "
1046-
"will be removed in a future version.",
1047-
FutureWarning,
1048-
stacklevel=find_stack_level(),
1049-
)
1050-
else:
1051-
verbose = False
1052-
10531023
# locals() should never be modified
10541024
kwds = locals().copy()
10551025
del kwds["filepath_or_buffer"]

pandas/tests/io/parser/common/test_verbose.py

-82
This file was deleted.

0 commit comments

Comments
 (0)