Skip to content

ENH: set __module__ on Series #60263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/source/development/contributing_docstring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ Finally, docstrings can also be appended to with the ``doc`` decorator.

In this example, we'll create a parent docstring normally (this is like
``pandas.core.generic.NDFrame``). Then we'll have two children (like
``pandas.core.series.Series`` and ``pandas.DataFrame``). We'll
``pandas.Series`` and ``pandas.DataFrame``). We'll
substitute the class names in this docstring.

.. code-block:: python
Expand Down Expand Up @@ -995,5 +995,5 @@ mapping function names to docstrings. Wherever possible, we prefer using
``doc``, since the docstring-writing processes is slightly closer to normal.

See ``pandas.core.generic.NDFrame.fillna`` for an example template, and
``pandas.core.series.Series.fillna`` and ``pandas.core.generic.frame.fillna``
``pandas.Series.fillna`` and ``pandas.core.generic.frame.fillna``
for the filled versions.
2 changes: 1 addition & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def iloc(self) -> _iLocIndexer:
With a scalar integer.

>>> type(df.iloc[0])
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
>>> df.iloc[0]
a 1
b 2
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
Substitution,
deprecate_nonkeyword_arguments,
doc,
set_module,
)
from pandas.util._validators import (
validate_ascending,
Expand Down Expand Up @@ -229,6 +230,7 @@
# error: Cannot override final attribute "size" (previously declared in base
# class "NDFrame")
# definition in base class "NDFrame"
@set_module("pandas")
class Series(base.IndexOpsMixin, NDFrame): # type: ignore[misc]
"""
One-dimensional ndarray with axis labels (including time series).
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/formats/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
>>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']
>>> s = pd.Series(text_values, index=int_values)
>>> s.info()
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
Index: 5 entries, 1 to 5
Series name: None
Non-Null Count Dtype
Expand All @@ -177,7 +177,7 @@
Prints a summary excluding information about its values:

>>> s.info(verbose=False)
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
Index: 5 entries, 1 to 5
dtypes: object(1)
memory usage: 80.0+ bytes
Expand All @@ -200,7 +200,7 @@
>>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6)
>>> s = pd.Series(np.random.choice(['a', 'b', 'c'], 10 ** 6))
>>> s.info()
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
RangeIndex: 1000000 entries, 0 to 999999
Series name: None
Non-Null Count Dtype
Expand All @@ -210,7 +210,7 @@
memory usage: 7.6+ MB

>>> s.info(memory_usage='deep')
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
RangeIndex: 1000000 entries, 0 to 999999
Series name: None
Non-Null Count Dtype
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def hist_frame(
>>> boxplot = df.boxplot(column=['Col1', 'Col2'], by='X',
... return_type='axes')
>>> type(boxplot)
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>

If ``return_type`` is `None`, a NumPy array of axes with the same shape
as ``layout`` is returned:
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,4 @@ def test_set_module():
assert pd.Period.__module__ == "pandas"
assert pd.Timestamp.__module__ == "pandas"
assert pd.Timedelta.__module__ == "pandas"
assert pd.Series.__module__ == "pandas"
2 changes: 1 addition & 1 deletion pandas/tests/io/pytables/test_append.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def test_append_raise(setup_path):
# series directly
msg = re.escape(
"cannot properly create the storer for: "
"[group->df,value-><class 'pandas.core.series.Series'>]"
"[group->df,value-><class 'pandas.Series'>]"
)
with pytest.raises(TypeError, match=msg):
store.append("df", Series(np.arange(10)))
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/methods/test_argsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_argsort_stable(self):
tm.assert_series_equal(qindexer.astype(np.intp), Series(qexpected))
msg = (
r"ndarray Expected type <class 'numpy\.ndarray'>, "
r"found <class 'pandas\.core\.series\.Series'> instead"
r"found <class 'pandas\.Series'> instead"
)
with pytest.raises(AssertionError, match=msg):
tm.assert_numpy_array_equal(qindexer, mindexer)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_info_series(

expected = textwrap.dedent(
"""\
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
MultiIndex: 10 entries, ('foo', 'one') to ('qux', 'three')
"""
)
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_info_memory():
memory_bytes = float(s.memory_usage())
expected = textwrap.dedent(
f"""\
<class 'pandas.core.series.Series'>
<class 'pandas.Series'>
RangeIndex: 2 entries, 0 to 1
Series name: None
Non-Null Count Dtype
Expand Down