-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Use a standard header for all rst files #24086
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -672,6 +672,7 @@ Otherwise, you need to do it manually: | |
|
||
import warnings | ||
|
||
|
||
def old_func(): | ||
"""Summary of the function. | ||
|
||
|
@@ -681,6 +682,7 @@ Otherwise, you need to do it manually: | |
warnings.warn('Use new_func instead.', FutureWarning, stacklevel=2) | ||
new_func() | ||
|
||
|
||
def new_func(): | ||
pass | ||
|
||
|
@@ -814,9 +816,8 @@ We would name this file ``test_cool_feature.py`` and put in an appropriate place | |
.. code-block:: python | ||
|
||
import pytest | ||
import numpy as np | ||
import pandas as pd | ||
from pandas.util import testing as tm | ||
import numpy as np # noqa: F811 | ||
import pandas as pd # noqa: F811 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This similar to the issue above. The tutorial presents a complete block of code to be copied and saved as a .py file. Without the explicit import, anyone following the tutorial will not be able to replicate the results. It might make sense to include this block as a non executable block. |
||
|
||
|
||
@pytest.mark.parametrize('dtype', ['int8', 'int16', 'int32', 'int64']) | ||
|
@@ -938,8 +939,10 @@ If your change involves checking that a warning is actually emitted, use | |
|
||
.. code-block:: python | ||
|
||
df = pd.DataFrame() | ||
import pandas.util.testing as tm | ||
|
||
|
||
df = pd.DataFrame() | ||
with tm.assert_produces_warning(FutureWarning): | ||
df.some_operation() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,6 @@ | ||
.. _cookbook: | ||
|
||
.. currentmodule:: pandas | ||
|
||
.. ipython:: python | ||
:suppress: | ||
|
||
import datetime | ||
import functools | ||
import glob | ||
import itertools | ||
import os | ||
|
||
import numpy as np | ||
import pandas as pd | ||
from pandas.compat import StringIO | ||
|
||
|
||
np.random.seed(123456) | ||
np.set_printoptions(precision=4, suppress=True) | ||
pd.options.display.max_rows = 15 | ||
|
||
{{ header }} | ||
|
||
******** | ||
Cookbook | ||
|
@@ -186,6 +167,8 @@ One could hard code: | |
|
||
.. ipython:: python | ||
|
||
import functools | ||
|
||
CritList = [Crit1, Crit2, Crit3] | ||
AllCrit = functools.reduce(lambda x, y: x & y, CritList) | ||
|
||
|
@@ -409,6 +392,8 @@ To take the cross section of the 1st level and 1st axis the index: | |
|
||
.. ipython:: python | ||
|
||
import itertools | ||
|
||
index = list(itertools.product(['Ada', 'Quinn', 'Violet'], | ||
['Comp', 'Math', 'Sci'])) | ||
headr = list(itertools.product(['Exams', 'Labs'], ['I', 'II'])) | ||
|
@@ -1022,6 +1007,9 @@ You can use the same approach to read all files matching a pattern. Here is an | |
|
||
.. ipython:: python | ||
|
||
import glob | ||
import os | ||
|
||
files = glob.glob('file_*.csv') | ||
result = pd.concat([pd.read_csv(f) for f in files], ignore_index=True) | ||
|
||
|
@@ -1081,6 +1069,8 @@ Option 1: pass rows explicitly to skip rows | |
|
||
.. ipython:: python | ||
|
||
from pandas.compat import StringIO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note: in the public docs I think we should use the standard python |
||
|
||
pd.read_csv(StringIO(data), sep=';', skiprows=[11, 12], | ||
index_col=0, parse_dates=True, header=10) | ||
|
||
|
@@ -1327,6 +1317,8 @@ The :ref:`Timedeltas <timedeltas.timedeltas>` docs. | |
|
||
.. ipython:: python | ||
|
||
import datetime | ||
|
||
s = pd.Series(pd.date_range('2012-1-1', periods=3, freq='D')) | ||
|
||
s - s.max() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,7 +207,7 @@ installed), make sure you have `pytest | |
|
||
:: | ||
|
||
>>> import pandas as pd | ||
>>> import pandas as pd # noqa: F811 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On this I agree with you. I can remove the explicit import. |
||
>>> pd.test() | ||
running: pytest --skip-slow --skip-network C:\Users\TP\Anaconda3\envs\py36\lib\site-packages\pandas | ||
============================= test session starts ============================= | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we use the header here? you can add the
F811
to the--bootstrap
parameter value if neededThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tutorial of sorts and the tutorial walks thru the process of importing pandas and numpy visibly (not with a :supress: ). I think without the visible import of pandas the tutorial will not make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. But can you still include the header in those files? Besides the imports, there is other stuff. And we will potentially add more, and expect to be applied to 100% of rst files. Thanks!