Repository: pandas-dev/pandas
Pull request: DOC: Do not mention private classes in the documentation
- [x] closes #26981
- [x] tests `python validate_docstrings.py --errors=GL04` passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`


Problem statement:
DOC: Do not mention private classes in the documentation
The public documentation shouldn't mention private classes, which the users are not expected to know about, and they could be removed in the future without proper deprecation.

We've got a script to find them, it can be run with `./scripts/validate_docstrings.py --errors=GL04`

Currently there are those cases:
```
pandas.Series.pipe: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.Series.where: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.Series.mask: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.Series.first_valid_index: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.Series.last_valid_index: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.Series.tshift: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.Series.to_dense: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.core.resample.Resampler.get_group: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.where: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.mask: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.pipe: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.tshift: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.first_valid_index: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.last_valid_index: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.DataFrame.to_dense: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.core.groupby.GroupBy.get_group: Private classes (NDFrame) should not be mentioned in public docstrings
pandas.core.groupby.DataFrameGroupBy.tshift: Private classes (NDFrame) should not be mentioned in public docstrings
```

I'd say in most cases we can replace `NDFrame` by `Series or DataFrame` but may be we can rephrase sentences too.

After all them are corrected, we should add to `ci/code_checks.sh` the code `GL04` to the part where we validate the documentation, so the CI checks for it, and mentions to `NDFrame` or other private classes are not reintroduced. Also in the same PR we can add `GL05`, which is not validated but there are no errors in the code for it, so we can start validating it.

Hints from issue discussion:
@datapythonista Can I take this issue?
Yes please, go for it. Thanks!

Commit message: DOC: Add 'GL04', 'GL05' to 'ci/code_checks' (#26981)

Patch to review:
diff --git a/ci/code_checks.sh b/ci/code_checks.sh
index a16580679ff54..ac86815569a0c 100755
--- a/ci/code_checks.sh
+++ b/ci/code_checks.sh
@@ -256,8 +256,8 @@ fi
 ### DOCSTRINGS ###
 if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
 
-    MSG='Validate docstrings (GL03, GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA05)' ; echo $MSG
-    $BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL03,GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA05
+    MSG='Validate docstrings (GL03, GL04, GL05, GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA05)' ; echo $MSG
+    $BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL03,GL04,GL05,GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA05
     RET=$(($RET + $?)) ; echo $MSG "DONE"
 
 fi
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index 360576ffdb00a..a5944754eac47 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -56,7 +56,7 @@
 # able to share
 _shared_docs = dict()
 _shared_doc_kwargs = dict(
-    axes='keywords for axes', klass='NDFrame',
+    axes='keywords for axes', klass='DataFrame',
     axes_single_arg='int or labels for object',
     args_transpose='axes to permute (int or label for object)',
     optional_by="""
@@ -1940,7 +1940,7 @@ def __array_wrap__(self, result, context=None):
 
     def to_dense(self):
         """
-        Return dense representation of NDFrame (as opposed to sparse).
+        Return dense representation of DataFrame (as opposed to sparse).
 
         .. deprecated:: 0.25.0
 
@@ -9011,7 +9011,7 @@ def tshift(self, periods=1, freq=None, axis=0):
 
         Returns
         -------
-        shifted : NDFrame
+        shifted : DataFrame
 
         Notes
         -----
@@ -10247,12 +10247,12 @@ def _find_valid_index(self, how):
         return idx
 
     @Appender(_shared_docs['valid_index'] % {'position': 'first',
-                                             'klass': 'NDFrame'})
+                                             'klass': 'DataFrame'})
     def first_valid_index(self):
         return self._find_valid_index('first')
 
     @Appender(_shared_docs['valid_index'] % {'position': 'last',
-                                             'klass': 'NDFrame'})
+                                             'klass': 'DataFrame'})
     def last_valid_index(self):
         return self._find_valid_index('last')
 
diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py
index 43950f2f503c8..64cacd60da30f 100644
--- a/pandas/core/groupby/groupby.py
+++ b/pandas/core/groupby/groupby.py
@@ -630,14 +630,14 @@ def curried(x):
 
     def get_group(self, name, obj=None):
         """
-        Construct NDFrame from group with provided name.
+        Construct DataFrame from group with provided name.
 
         Parameters
         ----------
         name : object
             the name of the group to get as a DataFrame
-        obj : NDFrame, default None
-            the NDFrame to take the DataFrame out of.  If
+        obj : DataFrame, default None
+            the DataFrame to take the DataFrame out of.  If
             it is None, the object groupby was called on will
             be used
 


Code review comments:
diff_hunk: @@ -56,7 +56,7 @@
 # able to share
 _shared_docs = dict()
 _shared_doc_kwargs = dict(
-    axes='keywords for axes', klass='NDFrame',
+    axes='keywords for axes', klass='DataFrame',
path: pandas/core/generic.py
text: @user1:
Inside this file (generic.py), I would replace all occurences of 'NDFrame' with `"Series/DataFrame"`, since those docstrings might be shared by both Series and DataFrame

@author:
Will do!

@author:
@user1 I have fixed the issue. How do you think?