Skip to content

Commit 3cc9f67

Browse files
DOC: Use standard header for .rst files
1 parent f74fc59 commit 3cc9f67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+361
-336
lines changed

doc/source/10min.rst

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
.. _10min:
22

3-
.. currentmodule:: pandas
4-
5-
.. ipython:: python
6-
:suppress:
7-
8-
import os
9-
import numpy as np
10-
11-
import pandas as pd
12-
13-
np.random.seed(123456)
14-
np.set_printoptions(precision=4, suppress=True)
15-
pd.options.display.max_rows = 15
16-
17-
# portions of this were borrowed from the
18-
# Pandas cheatsheet
19-
# created during the PyData Workshop-Sprint 2012
20-
# Hannah Chen, Henry Chow, Eric Cox, Robert Mauriello
21-
3+
{{ header }}
224

235
********************
246
10 Minutes to pandas
@@ -773,6 +755,7 @@ CSV
773755
.. ipython:: python
774756
:suppress:
775757
758+
import os
776759
os.remove('foo.csv')
777760
778761
HDF5

doc/source/advanced.rst

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
.. _advanced:
22

3-
.. currentmodule:: pandas
4-
5-
.. ipython:: python
6-
:suppress:
7-
8-
import numpy as np
9-
import pandas as pd
10-
np.random.seed(123456)
11-
np.set_printoptions(precision=4, suppress=True)
12-
pd.options.display.max_rows = 15
3+
{{ header }}
134

145
******************************
156
MultiIndex / Advanced Indexing

doc/source/basics.rst

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
.. currentmodule:: pandas
2-
3-
.. ipython:: python
4-
:suppress:
5-
6-
import numpy as np
7-
import pandas as pd
8-
9-
np.set_printoptions(precision=4, suppress=True)
10-
pd.options.display.max_rows = 15
11-
121
.. _basics:
132

3+
{{ header }}
4+
145
==============================
156
Essential Basic Functionality
167
==============================

doc/source/categorical.rst

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
.. _categorical:
22

3-
.. currentmodule:: pandas
4-
5-
.. ipython:: python
6-
:suppress:
7-
8-
import numpy as np
9-
import pandas as pd
10-
np.random.seed(123456)
11-
np.set_printoptions(precision=4, suppress=True)
12-
pd.options.display.max_rows = 15
13-
3+
{{ header }}
144

155
****************
166
Categorical Data

doc/source/comparison_with_r.rst

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
.. currentmodule:: pandas
21
.. _compare_with_r:
32

4-
.. ipython:: python
5-
:suppress:
6-
7-
import pandas as pd
8-
import numpy as np
9-
pd.options.display.max_rows = 15
3+
{{ header }}
104

115
Comparison with R / R libraries
126
*******************************

doc/source/comparison_with_sas.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ As is customary, we import pandas and NumPy as follows:
1414

1515
.. ipython:: python
1616
17-
import pandas as pd
18-
import numpy as np
17+
import pandas as pd # noqa: F811
18+
import numpy as np # noqa: F811
1919
2020
2121
.. note::

doc/source/computation.rst

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
.. currentmodule:: pandas
2-
3-
.. ipython:: python
4-
:suppress:
5-
6-
import numpy as np
7-
import matplotlib.pyplot as plt
8-
9-
import pandas as pd
10-
11-
np.random.seed(123456)
12-
np.set_printoptions(precision=4, suppress=True)
13-
pd.options.display.max_rows = 15
14-
15-
plt.close('all')
16-
171
.. _computation:
182

3+
{{ header }}
4+
195
Computational tools
206
===================
217

doc/source/conf.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -301,25 +301,25 @@
301301
}
302302

303303

304-
common_imports = """\
304+
header = """\
305305
.. currentmodule:: pandas
306306
307307
.. ipython:: python
308308
:suppress:
309309
310310
import numpy as np
311-
from pandas import *
312311
import pandas as pd
312+
313313
randn = np.random.randn
314+
np.random.seed(123456)
314315
np.set_printoptions(precision=4, suppress=True)
315-
options.display.max_rows = 15
316-
from pandas.compat import StringIO
316+
pd.options.display.max_rows = 15
317317
"""
318318

319319

320320
html_context = {
321321
'redirects': {old: new for old, new in moved_api_pages},
322-
'common_imports': common_imports,
322+
'header': header
323323
}
324324

325325
# If false, no module index is generated.

doc/source/contributing.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ Otherwise, you need to do it manually:
672672
673673
import warnings
674674
675+
675676
def old_func():
676677
"""Summary of the function.
677678
@@ -681,6 +682,7 @@ Otherwise, you need to do it manually:
681682
warnings.warn('Use new_func instead.', FutureWarning, stacklevel=2)
682683
new_func()
683684
685+
684686
def new_func():
685687
pass
686688
@@ -814,9 +816,8 @@ We would name this file ``test_cool_feature.py`` and put in an appropriate place
814816
.. code-block:: python
815817
816818
import pytest
817-
import numpy as np
818-
import pandas as pd
819-
from pandas.util import testing as tm
819+
import numpy as np # noqa: F811
820+
import pandas as pd # noqa: F811
820821
821822
822823
@pytest.mark.parametrize('dtype', ['int8', 'int16', 'int32', 'int64'])
@@ -938,8 +939,10 @@ If your change involves checking that a warning is actually emitted, use
938939

939940
.. code-block:: python
940941
941-
df = pd.DataFrame()
942+
import pandas.util.testing as tm
942943
944+
945+
df = pd.DataFrame()
943946
with tm.assert_produces_warning(FutureWarning):
944947
df.some_operation()
945948

doc/source/cookbook.rst

+12-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
.. _cookbook:
22

3-
.. currentmodule:: pandas
4-
5-
.. ipython:: python
6-
:suppress:
7-
8-
import datetime
9-
import functools
10-
import glob
11-
import itertools
12-
import os
13-
14-
import numpy as np
15-
import pandas as pd
16-
from pandas.compat import StringIO
17-
18-
19-
np.random.seed(123456)
20-
np.set_printoptions(precision=4, suppress=True)
21-
pd.options.display.max_rows = 15
22-
3+
{{ header }}
234

245
********
256
Cookbook
@@ -186,6 +167,8 @@ One could hard code:
186167

187168
.. ipython:: python
188169
170+
import functools
171+
189172
CritList = [Crit1, Crit2, Crit3]
190173
AllCrit = functools.reduce(lambda x, y: x & y, CritList)
191174
@@ -409,6 +392,8 @@ To take the cross section of the 1st level and 1st axis the index:
409392

410393
.. ipython:: python
411394
395+
import itertools
396+
412397
index = list(itertools.product(['Ada', 'Quinn', 'Violet'],
413398
['Comp', 'Math', 'Sci']))
414399
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
10221007

10231008
.. ipython:: python
10241009
1010+
import glob
1011+
import os
1012+
10251013
files = glob.glob('file_*.csv')
10261014
result = pd.concat([pd.read_csv(f) for f in files], ignore_index=True)
10271015
@@ -1081,6 +1069,8 @@ Option 1: pass rows explicitly to skip rows
10811069

10821070
.. ipython:: python
10831071
1072+
from pandas.compat import StringIO
1073+
10841074
pd.read_csv(StringIO(data), sep=';', skiprows=[11, 12],
10851075
index_col=0, parse_dates=True, header=10)
10861076
@@ -1327,6 +1317,8 @@ The :ref:`Timedeltas <timedeltas.timedeltas>` docs.
13271317

13281318
.. ipython:: python
13291319
1320+
import datetime
1321+
13301322
s = pd.Series(pd.date_range('2012-1-1', periods=3, freq='D'))
13311323
13321324
s - s.max()

doc/source/dsintro.rst

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
.. currentmodule:: pandas
2-
3-
.. ipython:: python
4-
:suppress:
5-
6-
import numpy as np
7-
np.set_printoptions(precision=4, suppress=True)
8-
import pandas as pd
9-
pd.set_option('display.precision', 4, 'display.max_columns', 8)
10-
pd.options.display.max_rows = 15
11-
12-
import matplotlib
13-
# matplotlib.style.use('default')
14-
import matplotlib.pyplot as plt
15-
plt.close('all')
16-
171
.. _dsintro:
182

3+
{{ header }}
4+
195
************************
206
Intro to Data Structures
217
************************

doc/source/enhancingperf.rst

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
.. _enhancingperf:
22

3-
.. currentmodule:: pandas
4-
5-
.. ipython:: python
6-
:suppress:
7-
8-
import numpy as np
9-
np.random.seed(123456)
10-
np.set_printoptions(precision=4, suppress=True)
11-
import pandas as pd
12-
pd.options.display.max_rows=15
13-
14-
import os
15-
import csv
16-
3+
{{ header }}
174

185
*********************
196
Enhancing Performance

doc/source/gotchas.rst

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
.. currentmodule:: pandas
21
.. _gotchas:
32

3+
{{ header }}
4+
45
********************************
56
Frequently Asked Questions (FAQ)
67
********************************
78

8-
.. ipython:: python
9-
:suppress:
10-
11-
import numpy as np
12-
import pandas as pd
13-
14-
np.random.seed(123456)
15-
np.set_printoptions(precision=4, suppress=True)
16-
pd.options.display.max_rows = 15
17-
189
.. _df-memory-usage:
1910

2011
DataFrame memory usage

doc/source/groupby.rst

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
.. currentmodule:: pandas
21
.. _groupby:
32

4-
.. ipython:: python
5-
:suppress:
6-
7-
import numpy as np
8-
import matplotlib.pyplot as plt
9-
10-
import pandas as pd
11-
12-
plt.close('all')
13-
14-
np.random.seed(123456)
15-
np.set_printoptions(precision=4, suppress=True)
16-
pd.options.display.max_rows = 15
3+
{{ header }}
174

185
*****************************
196
Group By: split-apply-combine

doc/source/indexing.rst

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
.. _indexing:
22

3-
.. currentmodule:: pandas
4-
5-
.. ipython:: python
6-
:suppress:
7-
8-
import numpy as np
9-
np.random.seed(123456)
10-
np.set_printoptions(precision=4, suppress=True)
11-
import pandas as pd
12-
pd.options.display.max_rows=15
3+
{{ header }}
134

145
***************************
156
Indexing and Selecting Data

doc/source/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ installed), make sure you have `pytest
207207

208208
::
209209

210-
>>> import pandas as pd
210+
>>> import pandas as pd # noqa: F811
211211
>>> pd.test()
212212
running: pytest --skip-slow --skip-network C:\Users\TP\Anaconda3\envs\py36\lib\site-packages\pandas
213213
============================= test session starts =============================

0 commit comments

Comments
 (0)