From 4d940da8716e1559dc69b6fef168861a59bdcd34 Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 10:01:39 +0100 Subject: [PATCH 1/8] replaced @doc with inline docstrings in series.py --- pandas/core/series.py | 602 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 590 insertions(+), 12 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index f92886b890254..febbe58359d51 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -159,9 +159,7 @@ import pandas.io.formats.format as fmt from pandas.io.formats.info import ( - INFO_DOCSTRING, SeriesInfo, - series_sub_kwargs, ) import pandas.plotting @@ -5115,11 +5113,8 @@ def set_axis( return super().set_axis(labels, axis=axis, copy=copy) # error: Cannot determine type of 'reindex' - @doc( - NDFrame.reindex, # type: ignore[has-type] - klass=_shared_doc_kwargs["klass"], - optional_reindex=_shared_doc_kwargs["optional_reindex"], - ) + # type: ignore[has-type] + def reindex( # type: ignore[override] self, index=None, @@ -5132,6 +5127,218 @@ def reindex( # type: ignore[override] limit: int | None = None, tolerance=None, ) -> Series: + """ + Conform Series to new index with optional filling logic. + + Places NA/NaN in locations having no value in the previous index. A new object + is produced unless the new index is equivalent to the current one and + ``copy=False``. + + Parameters + ---------- + method : {{None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}} + Method to use for filling holes in reindexed DataFrame. + Please note: this is only applicable to DataFrames/Series with a + monotonically increasing/decreasing index. + + * None (default): don't fill gaps + * pad / ffill: Propagate last valid observation forward to next + valid. + * backfill / bfill: Use next valid observation to fill gap. + * nearest: Use nearest valid observations to fill gap. + + copy : bool, default False + Return a new object, even if the passed indexes are the same. + + .. note:: + The `copy` keyword will change behavior in pandas 3.0. + `Copy-on-Write + `__ + will be enabled by default, which means that all methods with a + `copy` keyword will use a lazy copy mechanism to defer the copy and + ignore the `copy` keyword. The `copy` keyword will be removed in a + future version of pandas. + + You can already get the future behavior and improvements through + enabling copy on write ``pd.options.mode.copy_on_write = True`` + + .. deprecated:: 3.0.0 + level : int or name + Broadcast across a level, matching Index values on the + passed MultiIndex level. + fill_value : scalar, default np.nan + Value to use for missing values. Defaults to NaN, but can be any + "compatible" value. + limit : int, default None + Maximum number of consecutive elements to forward or backward fill. + tolerance : optional + Maximum distance between original and new labels for inexact + matches. The values of the index at the matching locations most + satisfy the equation ``abs(index[indexer] - target) <= tolerance``. + + Tolerance may be a scalar value, which applies the same tolerance + to all values, or list-like, which applies variable tolerance per + element. List-like includes list, tuple, array, Series, and must be + the same size as the index and its dtype must exactly match the + index's type. + + Returns + ------- + Series + Series with changed index. + + See Also + -------- + DataFrame.set_index : Set row labels. + DataFrame.reset_index : Remove row labels or move them to new columns. + DataFrame.reindex_like : Change to same indices as other DataFrame. + + Examples + -------- + ``DataFrame.reindex`` supports two calling conventions + + * ``(index=index_labels, columns=column_labels, ...)`` + * ``(labels, axis={{'index', 'columns'}}, ...)`` + + We *highly* recommend using keyword arguments to clarify your + intent. + + Create a DataFrame with some fictional data. + + >>> index = ["Firefox", "Chrome", "Safari", "IE10", "Konqueror"] + >>> columns = ["http_status", "response_time"] + >>> df = pd.DataFrame( + ... [[200, 0.04], [200, 0.02], [404, 0.07], [404, 0.08], [301, 1.0]], + ... columns=columns, + ... index=index, + ... ) + >>> df + http_status response_time + Firefox 200 0.04 + Chrome 200 0.02 + Safari 404 0.07 + IE10 404 0.08 + Konqueror 301 1.00 + + Create a new index and reindex the DataFrame. By default + values in the new index that do not have corresponding + records in the DataFrame are assigned ``NaN``. + + >>> new_index = ["Safari", "Iceweasel", "Comodo Dragon", "IE10", "Chrome"] + >>> df.reindex(new_index) + http_status response_time + Safari 404.0 0.07 + Iceweasel NaN NaN + Comodo Dragon NaN NaN + IE10 404.0 0.08 + Chrome 200.0 0.02 + + We can fill in the missing values by passing a value to + the keyword ``fill_value``. Because the index is not monotonically + increasing or decreasing, we cannot use arguments to the keyword + ``method`` to fill the ``NaN`` values. + + >>> df.reindex(new_index, fill_value=0) + http_status response_time + Safari 404 0.07 + Iceweasel 0 0.00 + Comodo Dragon 0 0.00 + IE10 404 0.08 + Chrome 200 0.02 + + >>> df.reindex(new_index, fill_value="missing") + http_status response_time + Safari 404 0.07 + Iceweasel missing missing + Comodo Dragon missing missing + IE10 404 0.08 + Chrome 200 0.02 + + We can also reindex the columns. + + >>> df.reindex(columns=["http_status", "user_agent"]) + http_status user_agent + Firefox 200 NaN + Chrome 200 NaN + Safari 404 NaN + IE10 404 NaN + Konqueror 301 NaN + + Or we can use "axis-style" keyword arguments + + >>> df.reindex(["http_status", "user_agent"], axis="columns") + http_status user_agent + Firefox 200 NaN + Chrome 200 NaN + Safari 404 NaN + IE10 404 NaN + Konqueror 301 NaN + + To further illustrate the filling functionality in + ``reindex``, we will create a DataFrame with a + monotonically increasing index (for example, a sequence + of dates). + + >>> date_index = pd.date_range("1/1/2010", periods=6, freq="D") + >>> df2 = pd.DataFrame( + ... {{"prices": [100, 101, np.nan, 100, 89, 88]}}, index=date_index + ... ) + >>> df2 + prices + 2010-01-01 100.0 + 2010-01-02 101.0 + 2010-01-03 NaN + 2010-01-04 100.0 + 2010-01-05 89.0 + 2010-01-06 88.0 + + Suppose we decide to expand the DataFrame to cover a wider + date range. + + >>> date_index2 = pd.date_range("12/29/2009", periods=10, freq="D") + >>> df2.reindex(date_index2) + prices + 2009-12-29 NaN + 2009-12-30 NaN + 2009-12-31 NaN + 2010-01-01 100.0 + 2010-01-02 101.0 + 2010-01-03 NaN + 2010-01-04 100.0 + 2010-01-05 89.0 + 2010-01-06 88.0 + 2010-01-07 NaN + + The index entries that did not have a value in the original data frame + (for example, '2009-12-29') are by default filled with ``NaN``. + If desired, we can fill in the missing values using one of several + options. + + For example, to back-propagate the last valid value to fill the ``NaN`` + values, pass ``bfill`` as an argument to the ``method`` keyword. + + >>> df2.reindex(date_index2, method="bfill") + prices + 2009-12-29 100.0 + 2009-12-30 100.0 + 2009-12-31 100.0 + 2010-01-01 100.0 + 2010-01-02 101.0 + 2010-01-03 NaN + 2010-01-04 100.0 + 2010-01-05 89.0 + 2010-01-06 88.0 + 2010-01-07 NaN + + Please note that the ``NaN`` value present in the original DataFrame + (at index value 2010-01-03) will not be filled by any of the + value propagation schemes. This is because filling while reindexing + does not look at DataFrame values, but only compares the original and + desired indexes. If you do want to fill in the ``NaN`` values present + in the original DataFrame, use the ``fillna()`` method. + + See the :ref:`user guide ` for more. + """ return super().reindex( index=index, method=method, @@ -5431,7 +5638,6 @@ def pop(self, item: Hashable) -> Any: """ return super().pop(item=item) - @doc(INFO_DOCSTRING, **series_sub_kwargs) def info( self, verbose: bool | None = None, @@ -5440,6 +5646,116 @@ def info( memory_usage: bool | str | None = None, show_counts: bool = True, ) -> None: + """ + Print a concise summary of a Series. + + This method prints information about a Series including + the index dtype"", non-NA values and memory usage. + "\n.. versionadded:: 1.4.0\n"\ + + Parameters + ---------- + verbose : bool, optional + Whether to print the full summary. By default, the setting in + ``pandas.options.display.max_info_columns`` is followed. + buf : writable buffer, defaults to sys.stdout + Where to send the output. By default, the output is printed to + sys.stdout. Pass a writable buffer if you need to further process + the output. + max_cols : int, optional + Unused, exists only for compatibility with DataFrame.info. + memory_usage : bool, str, optional + Specifies whether total memory usage of the Series + elements (including the index) should be displayed. By default, + this follows the ``pandas.options.display.memory_usage`` setting. + + True always show memory usage. False never shows memory usage. + A value of 'deep' is equivalent to "True with deep introspection". + Memory usage is shown in human-readable units (base-2 + representation). Without deep introspection a memory estimation is + made based in column dtype and number of rows assuming values + consume the same memory amount for corresponding dtypes. With deep + memory introspection, a real memory usage calculation is performed + at the cost of computational resources. See the + :ref:`Frequently Asked Questions ` for more + details. + show_counts : bool, optional + Whether to show the non-null counts. By default, this is shown + only if the DataFrame is smaller than + ``pandas.options.display.max_info_rows`` and + ``pandas.options.display.max_info_columns``. A value of True always + shows the counts, and False never shows the counts. + + Returns + ------- + None + This method prints a summary of a Series and returns None. + + See Also + -------- + Series.describe: Generate descriptive statistics of Series. + Series.memory_usage: Memory usage of Series. + + Examples + -------- + >>> int_values = [1, 2, 3, 4, 5] + >>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'] + >>> s = pd.Series(text_values, index=int_values) + >>> s.info() + + Index: 5 entries, 1 to 5 + Series name: None + Non-Null Count Dtype + -------------- ----- + 5 non-null object + dtypes: object(1) + memory usage: 80.0+ bytes + + Prints a summary excluding information about its values: + + >>> s.info(verbose=False) + + Index: 5 entries, 1 to 5 + dtypes: object(1) + memory usage: 80.0+ bytes + + Pipe output of Series.info to buffer instead of sys.stdout, get + buffer content and writes to a text file: + + >>> import io + >>> buffer = io.StringIO() + >>> s.info(buf=buffer) + >>> s = buffer.getvalue() + >>> with open("df_info.txt", "w", + ... encoding="utf-8") as f: # doctest: +SKIP + ... f.write(s) + 260 + + The `memory_usage` parameter allows deep introspection mode, specially + useful for big Series and fine-tune memory optimization: + + >>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6) + >>> s = pd.Series(np.random.choice(['a', 'b', 'c'], 10 ** 6)) + >>> s.info() + + RangeIndex: 1000000 entries, 0 to 999999 + Series name: None + Non-Null Count Dtype + -------------- ----- + 1000000 non-null object + dtypes: object(1) + memory usage: 7.6+ MB + + >>> s.info(memory_usage='deep') + + RangeIndex: 1000000 entries, 0 to 999999 + Series name: None + Non-Null Count Dtype + -------------- ----- + 1000000 non-null object + dtypes: object(1) + memory usage: 55.3 MB + """ return SeriesInfo(self, memory_usage).render( buf=buf, max_cols=max_cols, @@ -5794,28 +6110,290 @@ def case_when( return default # error: Cannot determine type of 'isna' - @doc(NDFrame.isna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type] + # type: ignore[has-type] + def isna(self) -> Series: + """ + Detect missing values. + + Return a boolean same-sized object indicating if the values are NA. + NA values, such as None or :attr:`numpy.NaN`, gets mapped to True + values. + Everything else gets mapped to False values. Characters such as empty + strings ``''`` or :attr:`numpy.inf` are not considered NA values. + + Returns + ------- + Series + Mask of bool values for each element in Series that + indicates whether an element is an NA value. + + See Also + -------- + Series.isnull : Alias of isna. + Series.notna : Boolean inverse of isna. + Series.dropna : Omit axes labels with missing values. + isna : Top-level isna. + + Examples + -------- + Show which entries in a DataFrame are NA. + + >>> df = pd.DataFrame( + ... dict( + ... age=[5, 6, np.nan], + ... born=[ + ... pd.NaT, + ... pd.Timestamp("1939-05-27"), + ... pd.Timestamp("1940-04-25"), + ... ], + ... name=["Alfred", "Batman", ""], + ... toy=[None, "Batmobile", "Joker"], + ... ) + ... ) + >>> df + age born name toy + 0 5.0 NaT Alfred NaN + 1 6.0 1939-05-27 Batman Batmobile + 2 NaN 1940-04-25 Joker + + >>> df.isna() + age born name toy + 0 False True False True + 1 False False False False + 2 True False False False + + Show which entries in a Series are NA. + + >>> ser = pd.Series([5, 6, np.nan]) + >>> ser + 0 5.0 + 1 6.0 + 2 NaN + dtype: float64 + + >>> ser.isna() + 0 False + 1 False + 2 True + dtype: bool + """ return NDFrame.isna(self) # error: Cannot determine type of 'isna' - @doc(NDFrame.isna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type] + # type: ignore[has-type] + def isnull(self) -> Series: """ Series.isnull is an alias for Series.isna. + + Detect missing values. + + Return a boolean same-sized object indicating if the values are NA. + NA values, such as None or :attr:`numpy.NaN`, gets mapped to True + values. + Everything else gets mapped to False values. Characters such as empty + strings ``''`` or :attr:`numpy.inf` are not considered NA values. + + Returns + ------- + Series + Mask of bool values for each element in Series that + indicates whether an element is an NA value. + + See Also + -------- + Series.isnull : Alias of isna. + Series.notna : Boolean inverse of isna. + Series.dropna : Omit axes labels with missing values. + isna : Top-level isna. + + Examples + -------- + Show which entries in a DataFrame are NA. + + >>> df = pd.DataFrame( + ... dict( + ... age=[5, 6, np.nan], + ... born=[ + ... pd.NaT, + ... pd.Timestamp("1939-05-27"), + ... pd.Timestamp("1940-04-25"), + ... ], + ... name=["Alfred", "Batman", ""], + ... toy=[None, "Batmobile", "Joker"], + ... ) + ... ) + >>> df + age born name toy + 0 5.0 NaT Alfred NaN + 1 6.0 1939-05-27 Batman Batmobile + 2 NaN 1940-04-25 Joker + + >>> df.isna() + age born name toy + 0 False True False True + 1 False False False False + 2 True False False False + + Show which entries in a Series are NA. + + >>> ser = pd.Series([5, 6, np.nan]) + >>> ser + 0 5.0 + 1 6.0 + 2 NaN + dtype: float64 + + >>> ser.isna() + 0 False + 1 False + 2 True + dtype: bool """ return super().isnull() # error: Cannot determine type of 'notna' - @doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type] + # type: ignore[has-type] + def notna(self) -> Series: + """ + Detect existing (non-missing) values. + + Return a boolean same-sized object indicating if the values are not NA. + Non-missing values get mapped to True. Characters such as empty + strings ``''`` or :attr:`numpy.inf` are not considered NA values. + NA values, such as None or :attr:`numpy.NaN`, get mapped to False + values. + + Returns + ------- + Series + Mask of bool values for each element in Series that + indicates whether an element is not an NA value. + + See Also + -------- + Series.notnull : Alias of notna. + Series.isna : Boolean inverse of notna. + Series.dropna : Omit axes labels with missing values. + notna : Top-level notna. + + Examples + -------- + Show which entries in a DataFrame are not NA. + + >>> df = pd.DataFrame( + ... dict( + ... age=[5, 6, np.nan], + ... born=[ + ... pd.NaT, + ... pd.Timestamp("1939-05-27"), + ... pd.Timestamp("1940-04-25"), + ... ], + ... name=["Alfred", "Batman", ""], + ... toy=[None, "Batmobile", "Joker"], + ... ) + ... ) + >>> df + age born name toy + 0 5.0 NaT Alfred NaN + 1 6.0 1939-05-27 Batman Batmobile + 2 NaN 1940-04-25 Joker + + >>> df.notna() + age born name toy + 0 True False True False + 1 True True True True + 2 False True True True + + Show which entries in a Series are not NA. + + >>> ser = pd.Series([5, 6, np.nan]) + >>> ser + 0 5.0 + 1 6.0 + 2 NaN + dtype: float64 + + >>> ser.notna() + 0 True + 1 True + 2 False + dtype: bool + """ return super().notna() # error: Cannot determine type of 'notna' - @doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type] + # type: ignore[has-type] + def notnull(self) -> Series: """ Series.notnull is an alias for Series.notna. + + Detect existing (non-missing) values. + + Return a boolean same-sized object indicating if the values are not NA. + Non-missing values get mapped to True. Characters such as empty + strings ``''`` or :attr:`numpy.inf` are not considered NA values. + NA values, such as None or :attr:`numpy.NaN`, get mapped to False + values. + + Returns + ------- + Series + Mask of bool values for each element in Series that + indicates whether an element is not an NA value. + + See Also + -------- + Series.notnull : Alias of notna. + Series.isna : Boolean inverse of notna. + Series.dropna : Omit axes labels with missing values. + notna : Top-level notna. + + Examples + -------- + Show which entries in a DataFrame are not NA. + + >>> df = pd.DataFrame( + ... dict( + ... age=[5, 6, np.nan], + ... born=[ + ... pd.NaT, + ... pd.Timestamp("1939-05-27"), + ... pd.Timestamp("1940-04-25"), + ... ], + ... name=["Alfred", "Batman", ""], + ... toy=[None, "Batmobile", "Joker"], + ... ) + ... ) + >>> df + age born name toy + 0 5.0 NaT Alfred NaN + 1 6.0 1939-05-27 Batman Batmobile + 2 NaN 1940-04-25 Joker + + >>> df.notna() + age born name toy + 0 True False True False + 1 True True True True + 2 False True True True + + Show which entries in a Series are not NA. + + >>> ser = pd.Series([5, 6, np.nan]) + >>> ser + 0 5.0 + 1 6.0 + 2 NaN + dtype: float64 + + >>> ser.notna() + 0 True + 1 True + 2 False + dtype: bool """ return super().notnull() From 88437b8d32ca35d47e3aa18c6c211e4672ac06fb Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 10:57:30 +0100 Subject: [PATCH 2/8] address CI issues --- pandas/core/series.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index febbe58359d51..819de8e1fe94c 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5113,7 +5113,6 @@ def set_axis( return super().set_axis(labels, axis=axis, copy=copy) # error: Cannot determine type of 'reindex' - # type: ignore[has-type] def reindex( # type: ignore[override] self, @@ -5650,8 +5649,9 @@ def info( Print a concise summary of a Series. This method prints information about a Series including - the index dtype"", non-NA values and memory usage. - "\n.. versionadded:: 1.4.0\n"\ + the index dtype, non-NA values and memory usage. + + .. versionadded:: 1.4.0 Parameters ---------- @@ -6110,7 +6110,6 @@ def case_when( return default # error: Cannot determine type of 'isna' - # type: ignore[has-type] def isna(self) -> Series: """ @@ -6181,10 +6180,10 @@ def isna(self) -> Series: return NDFrame.isna(self) # error: Cannot determine type of 'isna' - # type: ignore[has-type] def isnull(self) -> Series: """ + Series.isnull is an alias for Series.isna. Detect missing values. @@ -6254,7 +6253,6 @@ def isnull(self) -> Series: return super().isnull() # error: Cannot determine type of 'notna' - # type: ignore[has-type] def notna(self) -> Series: """ @@ -6325,10 +6323,10 @@ def notna(self) -> Series: return super().notna() # error: Cannot determine type of 'notna' - # type: ignore[has-type] def notnull(self) -> Series: """ + Series.notnull is an alias for Series.notna. Detect existing (non-missing) values. From 49114a21ae89876dcc2ae6a78732f355381d2396 Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 11:02:51 +0100 Subject: [PATCH 3/8] address CI issues --- pandas/core/series.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 819de8e1fe94c..082fd916c5897 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5650,7 +5650,7 @@ def info( This method prints information about a Series including the index dtype, non-NA values and memory usage. - + .. versionadded:: 1.4.0 Parameters @@ -5699,7 +5699,7 @@ def info( Examples -------- >>> int_values = [1, 2, 3, 4, 5] - >>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'] + >>> text_values = ["alpha", "beta", "gamma", "delta", "epsilon"] >>> s = pd.Series(text_values, index=int_values) >>> s.info() @@ -5726,16 +5726,15 @@ def info( >>> buffer = io.StringIO() >>> s.info(buf=buffer) >>> s = buffer.getvalue() - >>> with open("df_info.txt", "w", - ... encoding="utf-8") as f: # doctest: +SKIP + >>> with open("df_info.txt", "w", encoding="utf-8") as f: # doctest: +SKIP ... f.write(s) 260 The `memory_usage` parameter allows deep introspection mode, specially useful for big Series and fine-tune memory optimization: - >>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6) - >>> s = pd.Series(np.random.choice(['a', 'b', 'c'], 10 ** 6)) + >>> random_strings_array = np.random.choice(["a", "b", "c"], 10**6) + >>> s = pd.Series(np.random.choice(["a", "b", "c"], 10**6)) >>> s.info() RangeIndex: 1000000 entries, 0 to 999999 @@ -5746,7 +5745,7 @@ def info( dtypes: object(1) memory usage: 7.6+ MB - >>> s.info(memory_usage='deep') + >>> s.info(memory_usage="deep") RangeIndex: 1000000 entries, 0 to 999999 Series name: None @@ -6183,7 +6182,7 @@ def isna(self) -> Series: def isnull(self) -> Series: """ - + Series.isnull is an alias for Series.isna. Detect missing values. From 03d71173ab587175229e6c507d7b9de1a1280522 Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 11:26:59 +0100 Subject: [PATCH 4/8] address CI issues --- pandas/core/series.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 082fd916c5897..3352689056ae1 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6182,9 +6182,7 @@ def isna(self) -> Series: def isnull(self) -> Series: """ - Series.isnull is an alias for Series.isna. - Detect missing values. Return a boolean same-sized object indicating if the values are NA. @@ -6325,9 +6323,7 @@ def notna(self) -> Series: def notnull(self) -> Series: """ - Series.notnull is an alias for Series.notna. - Detect existing (non-missing) values. Return a boolean same-sized object indicating if the values are not NA. From 56b4e2bd3aa9c003eb2a182ac43410ee92bf59de Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 12:12:54 +0100 Subject: [PATCH 5/8] address CI issues in isnull and notnull --- pandas/core/series.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 3352689056ae1..327f1f6c0eea1 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5135,6 +5135,11 @@ def reindex( # type: ignore[override] Parameters ---------- + index : scalar, list-like, dict-like or function, optional + A scalar, list-like, dict-like or functions transformations to + apply to that axis' values. + axis : {0 or 'index'}, default 0 + The axis to rename. For `Series` this parameter is unused and defaults to 0. method : {{None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}} Method to use for filling holes in reindexed DataFrame. Please note: this is only applicable to DataFrames/Series with a @@ -6182,7 +6187,8 @@ def isna(self) -> Series: def isnull(self) -> Series: """ - Series.isnull is an alias for Series.isna. + Series.isnull is an alias for Series.isna. + Detect missing values. Return a boolean same-sized object indicating if the values are NA. @@ -6323,7 +6329,8 @@ def notna(self) -> Series: def notnull(self) -> Series: """ - Series.notnull is an alias for Series.notna. + Series.notnull is an alias for Series.notna. + Detect existing (non-missing) values. Return a boolean same-sized object indicating if the values are not NA. From b38b200037aa38e6768bb214f359bc309be4ddc3 Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 12:16:36 +0100 Subject: [PATCH 6/8] run pre-commit --- pandas/core/series.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 327f1f6c0eea1..15c92346eca7c 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6187,8 +6187,8 @@ def isna(self) -> Series: def isnull(self) -> Series: """ - Series.isnull is an alias for Series.isna. - + Series.isnull is an alias for Series.isna. + Detect missing values. Return a boolean same-sized object indicating if the values are NA. @@ -6329,8 +6329,8 @@ def notna(self) -> Series: def notnull(self) -> Series: """ - Series.notnull is an alias for Series.notna. - + Series.notnull is an alias for Series.notna. + Detect existing (non-missing) values. Return a boolean same-sized object indicating if the values are not NA. From 272ba720d5e1677c90a1a31b063c29461a73ca6a Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 12:58:40 +0100 Subject: [PATCH 7/8] address CI issues in isnull and notnull --- pandas/core/series.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 15c92346eca7c..35c46d6e4148f 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6187,6 +6187,7 @@ def isna(self) -> Series: def isnull(self) -> Series: """ + Series.isnull is an alias for Series.isna. Detect missing values. @@ -6329,6 +6330,7 @@ def notna(self) -> Series: def notnull(self) -> Series: """ + Series.notnull is an alias for Series.notna. Detect existing (non-missing) values. From 5b84f1cde4e90a53e74f65438dc757447ffe9149 Mon Sep 17 00:00:00 2001 From: Lonercode Date: Sat, 25 Oct 2025 13:35:55 +0100 Subject: [PATCH 8/8] reverted isnull and notnull due to failing test --- pandas/core/series.py | 136 +----------------------------------------- 1 file changed, 2 insertions(+), 134 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 35c46d6e4148f..609c950e2cff3 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6114,7 +6114,6 @@ def case_when( return default # error: Cannot determine type of 'isna' - def isna(self) -> Series: """ Detect missing values. @@ -6184,80 +6183,14 @@ def isna(self) -> Series: return NDFrame.isna(self) # error: Cannot determine type of 'isna' - + @doc(NDFrame.isna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type] def isnull(self) -> Series: """ - Series.isnull is an alias for Series.isna. - - Detect missing values. - - Return a boolean same-sized object indicating if the values are NA. - NA values, such as None or :attr:`numpy.NaN`, gets mapped to True - values. - Everything else gets mapped to False values. Characters such as empty - strings ``''`` or :attr:`numpy.inf` are not considered NA values. - - Returns - ------- - Series - Mask of bool values for each element in Series that - indicates whether an element is an NA value. - - See Also - -------- - Series.isnull : Alias of isna. - Series.notna : Boolean inverse of isna. - Series.dropna : Omit axes labels with missing values. - isna : Top-level isna. - - Examples - -------- - Show which entries in a DataFrame are NA. - - >>> df = pd.DataFrame( - ... dict( - ... age=[5, 6, np.nan], - ... born=[ - ... pd.NaT, - ... pd.Timestamp("1939-05-27"), - ... pd.Timestamp("1940-04-25"), - ... ], - ... name=["Alfred", "Batman", ""], - ... toy=[None, "Batmobile", "Joker"], - ... ) - ... ) - >>> df - age born name toy - 0 5.0 NaT Alfred NaN - 1 6.0 1939-05-27 Batman Batmobile - 2 NaN 1940-04-25 Joker - - >>> df.isna() - age born name toy - 0 False True False True - 1 False False False False - 2 True False False False - - Show which entries in a Series are NA. - - >>> ser = pd.Series([5, 6, np.nan]) - >>> ser - 0 5.0 - 1 6.0 - 2 NaN - dtype: float64 - - >>> ser.isna() - 0 False - 1 False - 2 True - dtype: bool """ return super().isnull() # error: Cannot determine type of 'notna' - def notna(self) -> Series: """ Detect existing (non-missing) values. @@ -6327,75 +6260,10 @@ def notna(self) -> Series: return super().notna() # error: Cannot determine type of 'notna' - + @doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type] def notnull(self) -> Series: """ - Series.notnull is an alias for Series.notna. - - Detect existing (non-missing) values. - - Return a boolean same-sized object indicating if the values are not NA. - Non-missing values get mapped to True. Characters such as empty - strings ``''`` or :attr:`numpy.inf` are not considered NA values. - NA values, such as None or :attr:`numpy.NaN`, get mapped to False - values. - - Returns - ------- - Series - Mask of bool values for each element in Series that - indicates whether an element is not an NA value. - - See Also - -------- - Series.notnull : Alias of notna. - Series.isna : Boolean inverse of notna. - Series.dropna : Omit axes labels with missing values. - notna : Top-level notna. - - Examples - -------- - Show which entries in a DataFrame are not NA. - - >>> df = pd.DataFrame( - ... dict( - ... age=[5, 6, np.nan], - ... born=[ - ... pd.NaT, - ... pd.Timestamp("1939-05-27"), - ... pd.Timestamp("1940-04-25"), - ... ], - ... name=["Alfred", "Batman", ""], - ... toy=[None, "Batmobile", "Joker"], - ... ) - ... ) - >>> df - age born name toy - 0 5.0 NaT Alfred NaN - 1 6.0 1939-05-27 Batman Batmobile - 2 NaN 1940-04-25 Joker - - >>> df.notna() - age born name toy - 0 True False True False - 1 True True True True - 2 False True True True - - Show which entries in a Series are not NA. - - >>> ser = pd.Series([5, 6, np.nan]) - >>> ser - 0 5.0 - 1 6.0 - 2 NaN - dtype: float64 - - >>> ser.notna() - 0 True - 1 True - 2 False - dtype: bool """ return super().notnull()