Skip to content

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

Merged
merged 3 commits into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions doc/source/10min.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
.. _10min:

.. currentmodule:: pandas

.. ipython:: python
:suppress:

import os
import numpy as np

import pandas as pd

np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15

# portions of this were borrowed from the
# Pandas cheatsheet
# created during the PyData Workshop-Sprint 2012
# Hannah Chen, Henry Chow, Eric Cox, Robert Mauriello

{{ header }}

********************
10 Minutes to pandas
Expand Down Expand Up @@ -773,6 +755,7 @@ CSV
.. ipython:: python
:suppress:

import os
os.remove('foo.csv')

HDF5
Expand Down
11 changes: 1 addition & 10 deletions doc/source/advanced.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
.. _advanced:

.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
import pandas as pd
np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15
{{ header }}

******************************
MultiIndex / Advanced Indexing
Expand Down
13 changes: 2 additions & 11 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
import pandas as pd

np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15

.. _basics:

{{ header }}

==============================
Essential Basic Functionality
==============================
Expand Down
12 changes: 1 addition & 11 deletions doc/source/categorical.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
.. _categorical:

.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
import pandas as pd
np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15

{{ header }}

****************
Categorical Data
Expand Down
8 changes: 1 addition & 7 deletions doc/source/comparison_with_r.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
.. currentmodule:: pandas
.. _compare_with_r:

.. ipython:: python
:suppress:

import pandas as pd
import numpy as np
pd.options.display.max_rows = 15
{{ header }}

Comparison with R / R libraries
*******************************
Expand Down
3 changes: 2 additions & 1 deletion doc/source/comparison_with_sas.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.. currentmodule:: pandas
.. _compare_with_sas:

{{ header }}

Comparison with SAS
********************
For potential users coming from `SAS <https://en.wikipedia.org/wiki/SAS_(software)>`__
Expand Down
3 changes: 2 additions & 1 deletion doc/source/comparison_with_sql.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.. currentmodule:: pandas
.. _compare_with_sql:

{{ header }}

Comparison with SQL
********************
Since many potential pandas users have some familiarity with
Expand Down
5 changes: 2 additions & 3 deletions doc/source/comparison_with_stata.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.. currentmodule:: pandas
.. _compare_with_stata:

{{ header }}

Comparison with Stata
*********************
For potential users coming from `Stata <https://en.wikipedia.org/wiki/Stata>`__
Expand Down Expand Up @@ -675,5 +676,3 @@ If out of core processing is needed, one possibility is the
`dask.dataframe <http://dask.pydata.org/en/latest/dataframe.html>`_
library, which provides a subset of pandas functionality for an
on-disk ``DataFrame``.


18 changes: 2 additions & 16 deletions doc/source/computation.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
import matplotlib.pyplot as plt

import pandas as pd

np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15

plt.close('all')

.. _computation:

{{ header }}

Computational tools
===================

Expand Down
10 changes: 5 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,25 +301,25 @@
}


common_imports = """\
header = """\
.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
from pandas import *
import pandas as pd

randn = np.random.randn
np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
options.display.max_rows = 15
from pandas.compat import StringIO
pd.options.display.max_rows = 15
"""


html_context = {
'redirects': {old: new for old, new in moved_api_pages},
'common_imports': common_imports,
'header': header
}

# If false, no module index is generated.
Expand Down
9 changes: 7 additions & 2 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.. _contributing:

{{ header }}

**********************
Contributing to pandas
**********************
Expand Down Expand Up @@ -672,6 +674,7 @@ Otherwise, you need to do it manually:

import warnings


def old_func():
"""Summary of the function.

Expand All @@ -681,6 +684,7 @@ Otherwise, you need to do it manually:
warnings.warn('Use new_func instead.', FutureWarning, stacklevel=2)
new_func()


def new_func():
pass

Expand Down Expand Up @@ -816,7 +820,6 @@ We would name this file ``test_cool_feature.py`` and put in an appropriate place
import pytest
import numpy as np
import pandas as pd
from pandas.util import testing as tm


@pytest.mark.parametrize('dtype', ['int8', 'int16', 'int32', 'int64'])
Expand Down Expand Up @@ -938,8 +941,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()

Expand Down
32 changes: 12 additions & 20 deletions doc/source/cookbook.rst
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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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']))
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -1081,6 +1069,8 @@ Option 1: pass rows explicitly to skip rows

.. ipython:: python

from pandas.compat import StringIO
Copy link
Member

Choose a reason for hiding this comment

The 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 from io import StringIO (as I don't think we should recommend people normal users to use pandas.compat)


pd.read_csv(StringIO(data), sep=';', skiprows=[11, 12],
index_col=0, parse_dates=True, header=10)

Expand Down Expand Up @@ -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()
Expand Down
18 changes: 2 additions & 16 deletions doc/source/dsintro.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
np.set_printoptions(precision=4, suppress=True)
import pandas as pd
pd.set_option('display.precision', 4, 'display.max_columns', 8)
pd.options.display.max_rows = 15

import matplotlib
# matplotlib.style.use('default')
import matplotlib.pyplot as plt
plt.close('all')

.. _dsintro:

{{ header }}

************************
Intro to Data Structures
************************
Expand Down
15 changes: 1 addition & 14 deletions doc/source/enhancingperf.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
.. _enhancingperf:

.. currentmodule:: pandas

.. ipython:: python
:suppress:

import numpy as np
np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
import pandas as pd
pd.options.display.max_rows=15

import os
import csv

{{ header }}

*********************
Enhancing Performance
Expand Down
13 changes: 2 additions & 11 deletions doc/source/gotchas.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
.. currentmodule:: pandas
.. _gotchas:

{{ header }}

********************************
Frequently Asked Questions (FAQ)
********************************

.. ipython:: python
:suppress:

import numpy as np
import pandas as pd

np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15

.. _df-memory-usage:

DataFrame memory usage
Expand Down
15 changes: 1 addition & 14 deletions doc/source/groupby.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
.. currentmodule:: pandas
.. _groupby:

.. ipython:: python
:suppress:

import numpy as np
import matplotlib.pyplot as plt

import pandas as pd

plt.close('all')

np.random.seed(123456)
np.set_printoptions(precision=4, suppress=True)
pd.options.display.max_rows = 15
{{ header }}

*****************************
Group By: split-apply-combine
Expand Down
Loading