Skip to content

Commit e51039a

Browse files
ENH: set __module__ for objects in pandas pd.DataFrame API (#55171)
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
1 parent a789288 commit e51039a

File tree

14 files changed

+43
-16
lines changed

14 files changed

+43
-16
lines changed

doc/source/development/contributing_docstring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ Finally, docstrings can also be appended to with the ``doc`` decorator.
940940

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

946946
.. code-block:: python

doc/source/user_guide/enhancingperf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ by evaluate arithmetic and boolean expression all at once for large :class:`~pan
453453
:func:`~pandas.eval` is many orders of magnitude slower for
454454
smaller expressions or objects than plain Python. A good rule of thumb is
455455
to only use :func:`~pandas.eval` when you have a
456-
:class:`.DataFrame` with more than 10,000 rows.
456+
:class:`~pandas.core.frame.DataFrame` with more than 10,000 rows.
457457

458458
Supported syntax
459459
~~~~~~~~~~~~~~~~

doc/source/user_guide/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6400,7 +6400,7 @@ ignored.
64006400
In [2]: df = pd.DataFrame({'A': np.random.randn(sz), 'B': [1] * sz})
64016401
64026402
In [3]: df.info()
6403-
<class 'pandas.core.frame.DataFrame'>
6403+
<class 'pandas.DataFrame'>
64046404
RangeIndex: 1000000 entries, 0 to 999999
64056405
Data columns (total 2 columns):
64066406
A 1000000 non-null float64

doc/source/whatsnew/v0.24.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ then all the columns are dummy-encoded, and a :class:`SparseDataFrame` was retur
840840
In [2]: df = pd.DataFrame({"A": [1, 2], "B": ['a', 'b'], "C": ['a', 'a']})
841841
842842
In [3]: type(pd.get_dummies(df, sparse=True))
843-
Out[3]: pandas.core.frame.DataFrame
843+
Out[3]: pandas.DataFrame
844844
845845
In [4]: type(pd.get_dummies(df[['B', 'C']], sparse=True))
846846
Out[4]: pandas.core.sparse.frame.SparseDataFrame

doc/source/whatsnew/v1.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ Extended verbose info output for :class:`~pandas.DataFrame`
414414
... "text_col": ["a", "b", "c"],
415415
... "float_col": [0.0, 0.1, 0.2]})
416416
In [2]: df.info(verbose=True)
417-
<class 'pandas.core.frame.DataFrame'>
417+
<class 'pandas.DataFrame'>
418418
RangeIndex: 3 entries, 0 to 2
419419
Data columns (total 3 columns):
420420
int_col 3 non-null int64

pandas/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def ignore_doctest_warning(item: pytest.Item, path: str, message: str) -> None:
125125
item : pytest.Item
126126
pytest test item.
127127
path : str
128-
Module path to Python object, e.g. "pandas.core.frame.DataFrame.append". A
128+
Module path to Python object, e.g. "pandas.DataFrame.append". A
129129
warning will be filtered when item.name ends with in given path. So it is
130130
sufficient to specify e.g. "DataFrame.append".
131131
message : str

pandas/core/frame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
Appender,
6666
Substitution,
6767
doc,
68+
set_module,
6869
)
6970
from pandas.util._exceptions import (
7071
find_stack_level,
@@ -498,6 +499,7 @@
498499
# DataFrame class
499500

500501

502+
@set_module("pandas")
501503
class DataFrame(NDFrame, OpsMixin):
502504
"""
503505
Two-dimensional, size-mutable, potentially heterogeneous tabular data.

pandas/core/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def iloc(self) -> _iLocIndexer:
227227
a b c d
228228
0 1 2 3 4
229229
>>> type(df.iloc[[0]])
230-
<class 'pandas.core.frame.DataFrame'>
230+
<class 'pandas.DataFrame'>
231231
232232
>>> df.iloc[[0, 1]]
233233
a b c d

pandas/io/formats/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ class DataFrameRenderer:
855855
- to_csv
856856
- to_latex
857857
858-
Called in pandas.core.frame.DataFrame:
858+
Called in pandas.DataFrame:
859859
- to_html
860860
- to_string
861861

pandas/io/formats/info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
Prints information of all columns:
7373
7474
>>> df.info(verbose=True)
75-
<class 'pandas.core.frame.DataFrame'>
75+
<class 'pandas.DataFrame'>
7676
RangeIndex: 5 entries, 0 to 4
7777
Data columns (total 3 columns):
7878
# Column Non-Null Count Dtype
@@ -87,7 +87,7 @@
8787
information:
8888
8989
>>> df.info(verbose=False)
90-
<class 'pandas.core.frame.DataFrame'>
90+
<class 'pandas.DataFrame'>
9191
RangeIndex: 5 entries, 0 to 4
9292
Columns: 3 entries, int_col to float_col
9393
dtypes: float64(1), int64(1), object(1)
@@ -115,7 +115,7 @@
115115
... 'column_3': np.random.choice(['a', 'b', 'c'], 10 ** 6)
116116
... })
117117
>>> df.info()
118-
<class 'pandas.core.frame.DataFrame'>
118+
<class 'pandas.DataFrame'>
119119
RangeIndex: 1000000 entries, 0 to 999999
120120
Data columns (total 3 columns):
121121
# Column Non-Null Count Dtype
@@ -127,7 +127,7 @@
127127
memory usage: 22.9+ MB
128128
129129
>>> df.info(memory_usage='deep')
130-
<class 'pandas.core.frame.DataFrame'>
130+
<class 'pandas.DataFrame'>
131131
RangeIndex: 1000000 entries, 0 to 999999
132132
Data columns (total 3 columns):
133133
# Column Non-Null Count Dtype

0 commit comments

Comments
 (0)