question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: validate_docstrings has many warnings

See original GitHub issue

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

Running ./ci/code_checks.sh docstrings results in many warnings:

$ ./ci/code_checks.sh docstrings
scripts/validate_docstrings.py:124: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  func = getattr(func, part)
scripts/validate_docstrings.py:124: FutureWarning: pandas.UInt64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  func = getattr(func, part)
scripts/validate_docstrings.py:124: FutureWarning: pandas.Float64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  func = getattr(func, part)
<doctest pandas.Index.equals[11]>:1: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  int64_idx = pd.Int64Index([1, 2, 3])
<doctest pandas.Index.equals[13]>:1: FutureWarning: pandas.UInt64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  uint64_idx = pd.UInt64Index([1, 2, 3])
<doctest pandas.Index.is_mixed[1]>:1: FutureWarning: Index.is_mixed is deprecated and will be removed in a future version. Check index.inferred_type directly instead.
  idx.is_mixed()
/home/taugspurger/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/numpydoc/validate.py:167: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  obj = getattr(obj, part)
/home/taugspurger/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/numpydoc/validate.py:167: FutureWarning: pandas.UInt64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  obj = getattr(obj, part)
/home/taugspurger/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/numpydoc/validate.py:167: FutureWarning: pandas.Float64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
  obj = getattr(obj, part)
<doctest pandas.Series.xs[5]>:1: PerformanceWarning: indexing past lexsort depth may impact performance.
  df.xs(('mammal', 'dog'))
<doctest pandas.DataFrame.empty[10]>:1: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
  ser_empty = pd.Series()
<doctest pandas.DataFrame.xs[5]>:1: PerformanceWarning: indexing past lexsort depth may impact performance.
  df.xs(('mammal', 'dog'))
<doctest pandas.date_range[8]>:1: FutureWarning: Argument `closed` is deprecated in favor of `inclusive`.
  pd.date_range(start='2017-01-01', end='2017-01-04', closed=None)
<doctest pandas.core.groupby.SeriesGroupBy.transform[2]>:1: FutureWarning: Dropping invalid columns in DataFrameGroupBy.transform is deprecated. In a future version, a TypeError will be raised. Before calling .transform, select only columns which should be valid for the function.
  grouped.transform(lambda x: (x - x.mean()) / x.std())
<doctest pandas.core.groupby.SeriesGroupBy.transform[3]>:1: FutureWarning: Dropping invalid columns in DataFrameGroupBy.transform is deprecated. In a future version, a TypeError will be raised. Before calling .transform, select only columns which should be valid for the function.
  grouped.transform(lambda x: x.max() - x.min())
<doctest pandas.core.groupby.DataFrameGroupBy.transform[2]>:1: FutureWarning: Dropping invalid columns in DataFrameGroupBy.transform is deprecated. In a future version, a TypeError will be raised. Before calling .transform, select only columns which should be valid for the function.
  grouped.transform(lambda x: (x - x.mean()) / x.std())
<doctest pandas.core.groupby.DataFrameGroupBy.transform[3]>:1: FutureWarning: Dropping invalid columns in DataFrameGroupBy.transform is deprecated. In a future version, a TypeError will be raised. Before calling .transform, select only columns which should be valid for the function.
  grouped.transform(lambda x: x.max() - x.min())
<doctest pandas.errors.DtypeWarning[2]>:1: DtypeWarning: Columns (0) have mixed types. Specify dtype option on import or set low_memory=False.
  df2 = pd.read_csv('test.csv')
<doctest pandas.core.window.rolling.Rolling.count[1]>:1: FutureWarning: min_periods=None will default to the size of window consistent with other methods in a future version. Specify min_periods=0 instead.
  s.rolling(2).count()

Issue Description

We shouldn’t have any unintentional warnings in our docstrings. These examples should be updated to not use the deprecated behavior.

Unfortunately, we don’t have the line numbers from the warnings. To find the problematic docstring, we probably just need to do a text search for something like Int64Index(

Expected Behavior

No warnings.

Installed Versions

Replace this line with the output of pd.show_versions()

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IsNotMyIPcommented, Nov 29, 2021

Sorry, but I can’t replicate this issue on my computer… Anyway, if anyone would like to contribute they just have to go to scripts/validate_docstrings.py and :

  • Update Int64Index func, which is going to be deprecated.
  • Update Index.mixed func to Numeric.Index

When i try to run the command it throw me back: Validate docstrings (GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS01, SS02, SS03, SS04, SS05, PR03, PR04, PR05, PR08, PRO9, PR10, EX04, RT01, RT04, RT05, SA02, SA03) Traceback (most recent call last): File "./ci/../scripts/validate_docstrings.py", line 431, in <module> main( File "./ci/../scripts/validate_docstrings.py", line 377, in main return print_validate_all_results( File "./ci/../scripts/validate_docstrings.py", line 321, in print_validate_all_results result = validate_all(prefix, ignore_deprecated) File "./ci/../scripts/validate_docstrings.py", line 286, in validate_all api_items += list(get_api_items(f)) File "./ci/../scripts/validate_docstrings.py", line 124, in get_api_items func = getattr(func, part) AttributeError: type object 'DateOffset' has no attribute 'is_month_start'

0reactions
seanjedicommented, Dec 1, 2022

Is this issue still open, or is there something I can work on?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sphinx (numpydoc) syntax warnings showing up in wrong file ...
In my docs/source/conf.py file, I have the numpydoc extension enabled, and it's generally working ... The error is from numpydoc validation.
Read more >
Troubleshooting - mkdocstrings
WARNING - Documentation file 'reference/parsers/docstrings.md' contains a link to ... Re-run the Mkdocs command with -v , and carefully read any traceback.
Read more >
Validation — numpydoc v1.6.0rc1.dev0 Manual - Read the Docs
This will cause a sphinx warning to be raised for any (non-module) docstring that has undocumented parameters in the signature. The full set...
Read more >
flake8-rst-docstrings - PyPI
Codes ending 99, for example RST499, indicate a previously unseen validation error for which we have yet to assign a unique validation code...
Read more >
doctest — Test interactive Python examples — Python 3.11.1 ...
There are several common ways to use doctest: To check that a module's docstrings are up-to-date by verifying that all interactive examples still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found