Skip to content

Commit 9c421f0

Browse files
authored
CLN: TODOs and FIXMEs (#44479)
1 parent 05ccc98 commit 9c421f0

File tree

19 files changed

+159
-178
lines changed

19 files changed

+159
-178
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,6 @@ def max(self, *, axis: int | None = None, skipna: bool = True, **kwargs):
14661466
Index.max : Return the maximum value in an Index.
14671467
Series.max : Return the maximum value in a Series.
14681468
"""
1469-
# TODO: skipna is broken with max.
1470-
# See https://github.com/pandas-dev/pandas/issues/24265
14711469
nv.validate_max((), kwargs)
14721470
nv.validate_minmax_axis(axis, self.ndim)
14731471

pandas/core/arrays/masked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def value_counts(self, dropna: bool = True) -> Series:
605605
data = self._data[~self._mask]
606606
value_counts = Index(data).value_counts()
607607

608-
# TODO(extension)
608+
# TODO(ExtensionIndex)
609609
# if we have allow Index to hold an ExtensionArray
610610
# this is easier
611611
index = value_counts.index._values.astype(object)

pandas/core/groupby/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ def _wrap_applied_output_series(
10391039
key_index,
10401040
) -> DataFrame | Series:
10411041
# this is to silence a DeprecationWarning
1042-
# TODO: Remove when default dtype of empty Series is object
1042+
# TODO(2.0): Remove when default dtype of empty Series is object
10431043
kwargs = first_not_none._construct_axes_dict()
10441044
backup = create_series_with_explicit_dtype(dtype_if_empty=object, **kwargs)
10451045
values = [x if (x is not None) else backup for x in values]

pandas/core/groupby/groupby.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,8 @@ def pct_change(self, periods=1, fill_method="pad", limit=None, freq=None, axis=0
33373337
Series or DataFrame
33383338
Percentage changes within each group.
33393339
"""
3340-
# TODO: Remove this conditional for SeriesGroupBy when GH#23918 is fixed
3340+
# TODO(GH#23918): Remove this conditional for SeriesGroupBy when
3341+
# GH#23918 is fixed
33413342
if freq is not None or axis != 0:
33423343
return self.apply(
33433344
lambda x: x.pct_change(

pandas/core/groupby/ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,8 @@ def result_arraylike(self) -> ArrayLike:
868868
Analogous to result_index, but returning an ndarray/ExtensionArray
869869
allowing us to retain ExtensionDtypes not supported by Index.
870870
"""
871-
# TODO: once Index supports arbitrary EAs, this can be removed in favor
872-
# of result_index
871+
# TODO(ExtensionIndex): once Index supports arbitrary EAs, this can
872+
# be removed in favor of result_index
873873
if len(self.groupings) == 1:
874874
return self.groupings[0].group_arraylike
875875

pandas/core/internals/managers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
operate_blockwise,
8181
)
8282

83-
# TODO: flexible with index=None and/or items=None
84-
8583
T = TypeVar("T", bound="BaseBlockManager")
8684

8785

pandas/core/nanops.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,16 +1781,20 @@ def na_accum_func(values: ArrayLike, accum_func, *, skipna: bool) -> ArrayLike:
17811781
# We need to define mask before masking NaTs
17821782
mask = isna(values)
17831783

1784-
if accum_func == np.minimum.accumulate:
1785-
# Note: the accum_func comparison fails as an "is" comparison
1786-
y = values.view("i8")
1787-
y[mask] = lib.i8max
1788-
changed = True
1789-
else:
1790-
y = values
1791-
changed = False
1784+
y = values.view("i8")
1785+
# Note: the accum_func comparison fails as an "is" comparison
1786+
changed = accum_func == np.minimum.accumulate
1787+
1788+
try:
1789+
if changed:
1790+
y[mask] = lib.i8max
1791+
1792+
result = accum_func(y, axis=0)
1793+
finally:
1794+
if changed:
1795+
# restore NaT elements
1796+
y[mask] = iNaT
17921797

1793-
result = accum_func(y.view("i8"), axis=0)
17941798
if skipna:
17951799
result[mask] = iNaT
17961800
elif accum_func == np.minimum.accumulate:
@@ -1800,10 +1804,6 @@ def na_accum_func(values: ArrayLike, accum_func, *, skipna: bool) -> ArrayLike:
18001804
# everything up to the first non-na entry stays NaT
18011805
result[: nz[0]] = iNaT
18021806

1803-
if changed:
1804-
# restore NaT elements
1805-
y[mask] = iNaT # TODO: could try/finally for this?
1806-
18071807
if isinstance(values.dtype, np.dtype):
18081808
result = result.view(orig_dtype)
18091809
else:

pandas/io/sas/sas7bdat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ class _Column:
103103
col_id: int
104104
name: str | bytes
105105
label: str | bytes
106-
format: str | bytes # TODO: i think allowing bytes is from py2 days
106+
format: str | bytes
107107
ctype: bytes
108108
length: int
109109

110110
def __init__(
111111
self,
112112
col_id: int,
113+
# These can be bytes when convert_header_text is False
113114
name: str | bytes,
114115
label: str | bytes,
115116
format: str | bytes,

pandas/io/sql.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,9 +2158,6 @@ def to_sql(
21582158
table.insert(chunksize, method)
21592159

21602160
def has_table(self, name: str, schema: str | None = None):
2161-
# TODO(wesm): unused?
2162-
# escape = _get_valid_sqlite_name
2163-
# esc_name = escape(name)
21642161

21652162
wld = "?"
21662163
query = f"SELECT name FROM sqlite_master WHERE type='table' AND name={wld};"

pandas/tests/apply/test_series_apply.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,18 +794,15 @@ def test_apply_to_timedelta():
794794
list_of_valid_strings = ["00:00:01", "00:00:02"]
795795
a = pd.to_timedelta(list_of_valid_strings)
796796
b = Series(list_of_valid_strings).apply(pd.to_timedelta)
797-
# FIXME: dont leave commented-out
798-
# Can't compare until apply on a Series gives the correct dtype
799-
# assert_series_equal(a, b)
797+
tm.assert_series_equal(Series(a), b)
800798

801799
list_of_strings = ["00:00:01", np.nan, pd.NaT, pd.NaT]
802800

803-
a = pd.to_timedelta(list_of_strings) # noqa
801+
a = pd.to_timedelta(list_of_strings)
804802
with tm.assert_produces_warning(FutureWarning, match="Inferring timedelta64"):
805803
ser = Series(list_of_strings)
806-
b = ser.apply(pd.to_timedelta) # noqa
807-
# Can't compare until apply on a Series gives the correct dtype
808-
# assert_series_equal(a, b)
804+
b = ser.apply(pd.to_timedelta)
805+
tm.assert_series_equal(Series(a), b)
809806

810807

811808
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)