Skip to content

Commit a1a644c

Browse files
saurav-chakravortyPingviinituutti
authored andcommitted
DOC: Use a standard header for all rst files (pandas-dev#24086)
1 parent 505575d commit a1a644c

Some content is hidden

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

76 files changed

+369
-338
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-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.. currentmodule:: pandas
21
.. _compare_with_sas:
32

3+
{{ header }}
4+
45
Comparison with SAS
56
********************
67
For potential users coming from `SAS <https://en.wikipedia.org/wiki/SAS_(software)>`__

doc/source/comparison_with_sql.rst

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

3+
{{ header }}
4+
45
Comparison with SQL
56
********************
67
Since many potential pandas users have some familiarity with

doc/source/comparison_with_stata.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.. currentmodule:: pandas
21
.. _compare_with_stata:
32

3+
{{ header }}
4+
45
Comparison with Stata
56
*********************
67
For potential users coming from `Stata <https://en.wikipedia.org/wiki/Stata>`__
@@ -675,5 +676,3 @@ If out of core processing is needed, one possibility is the
675676
`dask.dataframe <http://dask.pydata.org/en/latest/dataframe.html>`_
676677
library, which provides a subset of pandas functionality for an
677678
on-disk ``DataFrame``.
678-
679-

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-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. _contributing:
22

3+
{{ header }}
4+
35
**********************
46
Contributing to pandas
57
**********************
@@ -672,6 +674,7 @@ Otherwise, you need to do it manually:
672674
673675
import warnings
674676
677+
675678
def old_func():
676679
"""Summary of the function.
677680
@@ -681,6 +684,7 @@ Otherwise, you need to do it manually:
681684
warnings.warn('Use new_func instead.', FutureWarning, stacklevel=2)
682685
new_func()
683686
687+
684688
def new_func():
685689
pass
686690
@@ -816,7 +820,6 @@ We would name this file ``test_cool_feature.py`` and put in an appropriate place
816820
import pytest
817821
import numpy as np
818822
import pandas as pd
819-
from pandas.util import testing as tm
820823
821824
822825
@pytest.mark.parametrize('dtype', ['int8', 'int16', 'int32', 'int64'])
@@ -938,8 +941,10 @@ If your change involves checking that a warning is actually emitted, use
938941

939942
.. code-block:: python
940943
941-
df = pd.DataFrame()
944+
import pandas.util.testing as tm
945+
942946
947+
df = pd.DataFrame()
943948
with tm.assert_produces_warning(FutureWarning):
944949
df.some_operation()
945950

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

0 commit comments

Comments
 (0)