Skip to content

Commit

Permalink
CLN: Enforce verbose parameter deprecation in read_csv/read_table (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
lithomas1 authored Mar 22, 2024
1 parent a93fd6e commit eddd8e3
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 144 deletions.
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 @@ -256,6 +256,7 @@ Removal of prior version deprecations/changes
- Removed unused arguments ``*args`` and ``**kwargs`` in :class:`Resampler` methods (:issue:`50977`)
- Unrecognized timezones when parsing strings to datetimes now raises a ``ValueError`` (:issue:`51477`)
- Removed the :class:`Grouper` attributes ``ax``, ``groups``, ``indexer``, and ``obj`` (:issue:`51206`, :issue:`51182`)
- Removed deprecated keyword ``verbose`` on :func:`read_csv` and :func:`read_table` (:issue:`56556`)
- Removed the attribute ``dtypes`` from :class:`.DataFrameGroupBy` (:issue:`51997`)

.. ---------------------------------------------------------------------------
Expand Down
26 changes: 1 addition & 25 deletions pandas/_libs/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ from csv import (
QUOTE_NONE,
QUOTE_NONNUMERIC,
)
import time
import warnings

from pandas.util._exceptions import find_stack_level
Expand Down Expand Up @@ -344,10 +343,9 @@ cdef class TextReader:
object true_values, false_values
object handle
object orig_header
bint na_filter, keep_default_na, verbose, has_usecols, has_mi_columns
bint na_filter, keep_default_na, has_usecols, has_mi_columns
bint allow_leading_cols
uint64_t parser_start # this is modified after __init__
list clocks
const char *encoding_errors
kh_str_starts_t *false_set
kh_str_starts_t *true_set
Expand Down Expand Up @@ -400,7 +398,6 @@ cdef class TextReader:
bint allow_leading_cols=True,
skiprows=None,
skipfooter=0, # int64_t
bint verbose=False,
float_precision=None,
bint skip_blank_lines=True,
encoding_errors=b"strict",
Expand All @@ -417,9 +414,6 @@ cdef class TextReader:
self.parser = parser_new()
self.parser.chunksize = tokenize_chunksize

# For timekeeping
self.clocks = []

self.parser.usecols = (usecols is not None)

self._setup_parser_source(source)
Expand Down Expand Up @@ -507,8 +501,6 @@ cdef class TextReader:
self.converters = converters
self.na_filter = na_filter

self.verbose = verbose

if float_precision == "round_trip":
# see gh-15140
self.parser.double_converter = round_trip_wrapper
Expand Down Expand Up @@ -896,8 +888,6 @@ cdef class TextReader:
int64_t buffered_lines
int64_t irows

self._start_clock()

if rows is not None:
irows = rows
buffered_lines = self.parser.lines - self.parser_start
Expand All @@ -915,12 +905,8 @@ cdef class TextReader:

if self.parser_start >= self.parser.lines:
raise StopIteration
self._end_clock("Tokenization")

self._start_clock()
columns = self._convert_column_data(rows)
self._end_clock("Type conversion")
self._start_clock()
if len(columns) > 0:
rows_read = len(list(columns.values())[0])
# trim
Expand All @@ -929,18 +915,8 @@ cdef class TextReader:
parser_trim_buffers(self.parser)
self.parser_start -= rows_read

self._end_clock("Parser memory cleanup")

return columns

cdef _start_clock(self):
self.clocks.append(time.time())

cdef _end_clock(self, str what):
if self.verbose:
elapsed = time.time() - self.clocks.pop(-1)
print(f"{what} took: {elapsed * 1000:.2f} ms")

def set_noconvert(self, i: int) -> None:
self.noconvert.add(i)

Expand Down
4 changes: 0 additions & 4 deletions pandas/io/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ def _convert_to_ndarrays(
dct: Mapping,
na_values,
na_fvalues,
verbose: bool = False,
converters=None,
dtypes=None,
) -> dict[Any, np.ndarray]:
Expand Down Expand Up @@ -596,8 +595,6 @@ def _convert_to_ndarrays(
cvals = self._cast_types(cvals, cast_type, c)

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

@final
Expand Down Expand Up @@ -1236,7 +1233,6 @@ def converter(*date_cols, col: Hashable):
"usecols": None,
# 'iterator': False,
"chunksize": None,
"verbose": False,
"encoding": None,
"compression": None,
"skip_blank_lines": True,
Expand Down
3 changes: 0 additions & 3 deletions pandas/io/parsers/python_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def __init__(self, f: ReadCsvBuffer[str] | list, **kwds) -> None:
if "has_index_names" in kwds:
self.has_index_names = kwds["has_index_names"]

self.verbose = kwds["verbose"]

self.thousands = kwds["thousands"]
self.decimal = kwds["decimal"]

Expand Down Expand Up @@ -372,7 +370,6 @@ def _convert_data(
data,
clean_na_values,
clean_na_fvalues,
self.verbose,
clean_conv,
clean_dtypes,
)
Expand Down
30 changes: 0 additions & 30 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
)
keep_default_na: bool
na_filter: bool
verbose: bool | lib.NoDefault
skip_blank_lines: bool
parse_dates: bool | Sequence[Hashable] | None
infer_datetime_format: bool | lib.NoDefault
Expand Down Expand Up @@ -295,10 +294,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
Detect missing value markers (empty strings and the value of ``na_values``). In
data without any ``NA`` values, passing ``na_filter=False`` can improve the
performance of reading a large file.
verbose : bool, default False
Indicate number of ``NA`` values placed in non-numeric columns.
.. deprecated:: 2.2.0
skip_blank_lines : bool, default True
If ``True``, skip over blank lines rather than interpreting as ``NaN`` values.
parse_dates : bool, None, list of Hashable, list of lists or dict of {{Hashable : \
Expand Down Expand Up @@ -556,7 +551,6 @@ class _Fwf_Defaults(TypedDict):
"converters",
"iterator",
"dayfirst",
"verbose",
"skipinitialspace",
"low_memory",
}
Expand Down Expand Up @@ -755,7 +749,6 @@ def read_csv(
| None = None,
keep_default_na: bool = True,
na_filter: bool = True,
verbose: bool | lib.NoDefault = lib.no_default,
skip_blank_lines: bool = True,
# Datetime Handling
parse_dates: bool | Sequence[Hashable] | None = None,
Expand Down Expand Up @@ -845,17 +838,6 @@ def read_csv(
else:
delim_whitespace = False

if verbose is not lib.no_default:
# GH#55569
warnings.warn(
"The 'verbose' keyword in pd.read_csv is deprecated and "
"will be removed in a future version.",
FutureWarning,
stacklevel=find_stack_level(),
)
else:
verbose = False

# locals() should never be modified
kwds = locals().copy()
del kwds["filepath_or_buffer"]
Expand Down Expand Up @@ -958,7 +940,6 @@ def read_table(
| None = None,
keep_default_na: bool = True,
na_filter: bool = True,
verbose: bool | lib.NoDefault = lib.no_default,
skip_blank_lines: bool = True,
# Datetime Handling
parse_dates: bool | Sequence[Hashable] | None = None,
Expand Down Expand Up @@ -1039,17 +1020,6 @@ def read_table(
else:
delim_whitespace = False

if verbose is not lib.no_default:
# GH#55569
warnings.warn(
"The 'verbose' keyword in pd.read_table is deprecated and "
"will be removed in a future version.",
FutureWarning,
stacklevel=find_stack_level(),
)
else:
verbose = False

# locals() should never be modified
kwds = locals().copy()
del kwds["filepath_or_buffer"]
Expand Down
82 changes: 0 additions & 82 deletions pandas/tests/io/parser/common/test_verbose.py

This file was deleted.

0 comments on commit eddd8e3

Please sign in to comment.