Skip to content

DOC: Remove pandas. prefix from See Also section in Series #23659

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

Closed
datapythonista opened this issue Nov 13, 2018 · 2 comments · Fixed by #23749
Closed

DOC: Remove pandas. prefix from See Also section in Series #23659

datapythonista opened this issue Nov 13, 2018 · 2 comments · Fixed by #23749
Labels
Milestone

Comments

@datapythonista
Copy link
Member

When referencing other functions in docstrings See Also section, pandas is assumed to be the default project. So, this would be correct:

def shape():
    """
    See Also
    --------
    numpy.ndim : Number of dimensions property in numpy.
    DataFrame.ndim : Number of dimensions property in pandas DataFrame.

and this would be incorrect:

def shape():
    """
    See Also
    --------
    numpy.ndim : Number of dimensions property in numpy.
    pandas.DataFrame.ndim : Number of dimensions property in pandas DataFrame.

Note the pandas. before DataFrame.ndim, which is not required and adds noise.

To get all the cases in which this happens in Series, we can use:

$ ./scripts/validate_docstrings.py --prefix=pandas.Series --errors=SA05
pandas.Series.astype: pandas.to_datetime in `See Also` section does not need `pandas` prefix, use to_datetime instead.
pandas.Series.astype: pandas.to_timedelta in `See Also` section does not need `pandas` prefix, use to_timedelta instead.
pandas.Series.astype: pandas.to_numeric in `See Also` section does not need `pandas` prefix, use to_numeric instead.
pandas.Series.infer_objects: pandas.to_datetime in `See Also` section does not need `pandas` prefix, use to_datetime instead.
pandas.Series.infer_objects: pandas.to_timedelta in `See Also` section does not need `pandas` prefix, use to_timedelta instead.
pandas.Series.infer_objects: pandas.to_numeric in `See Also` section does not need `pandas` prefix, use to_numeric instead.
pandas.Series.convert_objects: pandas.to_datetime in `See Also` section does not need `pandas` prefix, use to_datetime instead.
pandas.Series.convert_objects: pandas.to_timedelta in `See Also` section does not need `pandas` prefix, use to_timedelta instead.
pandas.Series.convert_objects: pandas.to_numeric in `See Also` section does not need `pandas` prefix, use to_numeric instead.
pandas.Series.agg: pandas.Series.apply in `See Also` section does not need `pandas` prefix, use Series.apply instead.
pandas.Series.agg: pandas.Series.transform in `See Also` section does not need `pandas` prefix, use Series.transform instead.
pandas.Series.aggregate: pandas.Series.apply in `See Also` section does not need `pandas` prefix, use Series.apply instead.
pandas.Series.aggregate: pandas.Series.transform in `See Also` section does not need `pandas` prefix, use Series.transform instead.
pandas.Series.pipe: pandas.DataFrame.apply in `See Also` section does not need `pandas` prefix, use DataFrame.apply instead.
pandas.Series.pipe: pandas.DataFrame.applymap in `See Also` section does not need `pandas` prefix, use DataFrame.applymap instead.
pandas.Series.pipe: pandas.Series.map in `See Also` section does not need `pandas` prefix, use Series.map instead.
pandas.Series.all: pandas.Series.all in `See Also` section does not need `pandas` prefix, use Series.all instead.
pandas.Series.all: pandas.DataFrame.any in `See Also` section does not need `pandas` prefix, use DataFrame.any instead.
pandas.Series.between: pandas.Series.gt in `See Also` section does not need `pandas` prefix, use Series.gt instead.
pandas.Series.between: pandas.Series.lt in `See Also` section does not need `pandas` prefix, use Series.lt instead.
pandas.Series.cummax: pandas.core.window.Expanding.max in `See Also` section does not need `pandas` prefix, use core.window.Expanding.max instead.
pandas.Series.cummin: pandas.core.window.Expanding.min in `See Also` section does not need `pandas` prefix, use core.window.Expanding.min instead.
pandas.Series.cumprod: pandas.core.window.Expanding.prod in `See Also` section does not need `pandas` prefix, use core.window.Expanding.prod instead.
pandas.Series.cumsum: pandas.core.window.Expanding.sum in `See Also` section does not need `pandas` prefix, use core.window.Expanding.sum instead.
pandas.Series.factorize: pandas.cut in `See Also` section does not need `pandas` prefix, use cut instead.
pandas.Series.factorize: pandas.unique in `See Also` section does not need `pandas` prefix, use unique instead.
pandas.Series.quantile: pandas.core.window.Rolling.quantile in `See Also` section does not need `pandas` prefix, use core.window.Rolling.quantile instead.
pandas.Series.unique: pandas.unique in `See Also` section does not need `pandas` prefix, use unique instead.
pandas.Series.duplicated: pandas.Index.duplicated in `See Also` section does not need `pandas` prefix, use Index.duplicated instead.
pandas.Series.duplicated: pandas.DataFrame.duplicated in `See Also` section does not need `pandas` prefix, use DataFrame.duplicated instead.
pandas.Series.duplicated: pandas.Series.drop_duplicates in `See Also` section does not need `pandas` prefix, use Series.drop_duplicates instead.
pandas.Series.head: pandas.DataFrame.tail in `See Also` section does not need `pandas` prefix, use DataFrame.tail instead.
pandas.Series.isin: pandas.DataFrame.isin in `See Also` section does not need `pandas` prefix, use DataFrame.isin instead.
pandas.Series.rename: pandas.Series.rename_axis in `See Also` section does not need `pandas` prefix, use Series.rename_axis instead.
pandas.Series.rename_axis: pandas.Series.rename in `See Also` section does not need `pandas` prefix, use Series.rename instead.
pandas.Series.rename_axis: pandas.DataFrame.rename in `See Also` section does not need `pandas` prefix, use DataFrame.rename instead.
pandas.Series.rename_axis: pandas.Index.rename in `See Also` section does not need `pandas` prefix, use Index.rename instead.
pandas.Series.set_axis: pandas.DataFrame.rename_axis in `See Also` section does not need `pandas` prefix, use DataFrame.rename_axis instead.
pandas.Series.tail: pandas.DataFrame.head in `See Also` section does not need `pandas` prefix, use DataFrame.head instead.
pandas.Series.filter: pandas.DataFrame.loc in `See Also` section does not need `pandas` prefix, use DataFrame.loc instead.
pandas.Series.append: pandas.concat in `See Also` section does not need `pandas` prefix, use concat instead.
pandas.Series.dt.to_period: pandas.PeriodIndex in `See Also` section does not need `pandas` prefix, use PeriodIndex instead.
pandas.Series.dt.to_period: pandas.DatetimeIndex.to_pydatetime in `See Also` section does not need `pandas` prefix, use DatetimeIndex.to_pydatetime instead.
pandas.Series.dt.strftime: pandas.to_datetime in `See Also` section does not need `pandas` prefix, use to_datetime instead.
pandas.Series.str.get_dummies: pandas.get_dummies in `See Also` section does not need `pandas` prefix, use get_dummies instead.
pandas.Series.to_csv: pandas.read_csv in `See Also` section does not need `pandas` prefix, use read_csv instead.
pandas.Series.to_csv: pandas.to_excel in `See Also` section does not need `pandas` prefix, use to_excel instead.
pandas.Series.to_excel: pandas.read_excel in `See Also` section does not need `pandas` prefix, use read_excel instead.
pandas.Series.to_excel: pandas.ExcelWriter in `See Also` section does not need `pandas` prefix, use ExcelWriter instead.
pandas.Series.to_sql: pandas.read_sql in `See Also` section does not need `pandas` prefix, use read_sql instead.
pandas.Series.to_json: pandas.read_json in `See Also` section does not need `pandas` prefix, use read_json instead.
pandas.Series.as_matrix: pandas.DataFrame.values in `See Also` section does not need `pandas` prefix, use DataFrame.values instead.
pandas.Series.from_csv: pandas.read_csv in `See Also` section does not need `pandas` prefix, use read_csv instead.

In this issue we should fix all these cases, and check that the previous command don't report any case.

@TomAugspurger
Copy link
Contributor

Note that sometimes the prefix is necessary. The docstring for pandas.io.formats.style.Styler links to pandas.DataFrame.style, not DataFrame.style. I think the rule is that that See Also uses the current module in api.rst, which will almost always be just pandas. Since Styler isn't in the top-level namespace, we need the full pandas.DataFrame.style in the "See Also"

@CalmDownKarm
Copy link
Contributor

I'd like to take this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants