Skip to content

Commit 08c920e

Browse files
datapythonistajreback
authored andcommitted
DOC: Fixing more doc warnings (#24438)
1 parent 9ed49eb commit 08c920e

File tree

11 files changed

+28
-33
lines changed

11 files changed

+28
-33
lines changed

doc/source/advanced.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,12 @@ a ``Categorical`` will return a ``CategoricalIndex``, indexed according to the c
778778
of the **passed** ``Categorical`` dtype. This allows one to arbitrarily index these even with
779779
values **not** in the categories, similarly to how you can reindex **any** pandas index.
780780

781-
.. ipython :: python
781+
.. ipython:: python
782782
783-
df2.reindex(['a','e'])
784-
df2.reindex(['a','e']).index
785-
df2.reindex(pd.Categorical(['a','e'],categories=list('abcde')))
786-
df2.reindex(pd.Categorical(['a','e'],categories=list('abcde'))).index
783+
df2.reindex(['a', 'e'])
784+
df2.reindex(['a', 'e']).index
785+
df2.reindex(pd.Categorical(['a', 'e'], categories=list('abcde')))
786+
df2.reindex(pd.Categorical(['a', 'e'], categories=list('abcde'))).index
787787
788788
.. warning::
789789

@@ -1040,7 +1040,8 @@ than integer locations. Therefore, with an integer axis index *only*
10401040
label-based indexing is possible with the standard tools like ``.loc``. The
10411041
following code will generate exceptions:
10421042

1043-
.. code-block:: python
1043+
.. ipython:: python
1044+
:okexcept:
10441045
10451046
s = pd.Series(range(5))
10461047
s[-1]
@@ -1130,7 +1131,7 @@ index can be somewhat complicated. For example, the following does not work:
11301131

11311132
::
11321133

1133-
s.loc['c':'e'+1]
1134+
s.loc['c':'e' + 1]
11341135

11351136
A very common use case is to limit a time series to start and end at two
11361137
specific dates. To enable this, we made the design to make label-based

doc/source/categorical.rst

+4-7
Original file line numberDiff line numberDiff line change
@@ -977,21 +977,17 @@ categorical (categories and ordering). So if you read back the CSV file you have
977977
relevant columns back to `category` and assign the right categories and categories ordering.
978978

979979
.. ipython:: python
980-
:suppress:
981980
982-
983-
.. ipython:: python
984-
985-
from pandas.compat import StringIO
981+
import io
986982
s = pd.Series(pd.Categorical(['a', 'b', 'b', 'a', 'a', 'd']))
987983
# rename the categories
988984
s.cat.categories = ["very good", "good", "bad"]
989985
# reorder the categories and add missing categories
990986
s = s.cat.set_categories(["very bad", "bad", "medium", "good", "very good"])
991987
df = pd.DataFrame({"cats": s, "vals": [1, 2, 3, 4, 5, 6]})
992-
csv = StringIO()
988+
csv = io.StringIO()
993989
df.to_csv(csv)
994-
df2 = pd.read_csv(StringIO(csv.getvalue()))
990+
df2 = pd.read_csv(io.StringIO(csv.getvalue()))
995991
df2.dtypes
996992
df2["cats"]
997993
# Redo the category
@@ -1206,6 +1202,7 @@ Use ``copy=True`` to prevent such a behaviour or simply don't reuse ``Categorica
12061202
cat
12071203
12081204
.. note::
1205+
12091206
This also happens in some cases when you supply a NumPy array instead of a ``Categorical``:
12101207
using an int array (e.g. ``np.array([1,2,3,4])``) will exhibit the same behavior, while using
12111208
a string array (e.g. ``np.array(["a","b","c","a"])``) will not.

doc/source/conf.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@
296296
np.random.seed(123456)
297297
np.set_printoptions(precision=4, suppress=True)
298298
pd.options.display.max_rows = 15
299-
"""
299+
300+
import os
301+
os.chdir('{}')
302+
""".format(os.path.dirname(os.path.dirname(__file__)))
300303

301304

302305
html_context = {

doc/source/cookbook.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ the following Python code will read the binary file ``'binary.dat'`` into a
12361236
pandas ``DataFrame``, where each element of the struct corresponds to a column
12371237
in the frame:
12381238

1239-
.. code-block:: python
1239+
.. ipython:: python
12401240
12411241
names = 'count', 'avg', 'scale'
12421242
@@ -1399,7 +1399,6 @@ of the data values:
13991399

14001400
.. ipython:: python
14011401
1402-
14031402
def expand_grid(data_dict):
14041403
rows = itertools.product(*data_dict.values())
14051404
return pd.DataFrame.from_records(rows, columns=data_dict.keys())

doc/source/gotchas.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@ Byte-Ordering Issues
301301
--------------------
302302
Occasionally you may have to deal with data that were created on a machine with
303303
a different byte order than the one on which you are running Python. A common
304-
symptom of this issue is an error like:
305-
306-
.. code-block:: python-traceback
304+
symptom of this issue is an error like:::
307305

308306
Traceback
309307
...

doc/source/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4879,7 +4879,7 @@ below and the SQLAlchemy `documentation <https://docs.sqlalchemy.org/en/latest/c
48794879
48804880
If you want to manage your own connections you can pass one of those instead:
48814881

4882-
.. code-block:: python
4882+
.. ipython:: python
48834883
48844884
with engine.connect() as conn, conn.begin():
48854885
data = pd.read_sql_table('data', conn)

doc/source/merging.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ This is equivalent but less verbose and more memory efficient / faster than this
11221122
labels=['left', 'right'], vertical=False);
11231123
plt.close('all');
11241124
1125+
.. _merging.join_with_two_multi_indexes:
1126+
11251127
Joining with two MultiIndexes
11261128
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11271129

doc/source/sparse.rst

+2-7
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ It raises if any value cannot be coerced to specified dtype.
151151
.. code-block:: ipython
152152
153153
In [1]: ss = pd.Series([1, np.nan, np.nan]).to_sparse()
154+
Out[1]:
154155
0 1.0
155156
1 NaN
156157
2 NaN
@@ -160,6 +161,7 @@ It raises if any value cannot be coerced to specified dtype.
160161
Block lengths: array([1], dtype=int32)
161162
162163
In [2]: ss.astype(np.int64)
164+
Out[2]:
163165
ValueError: unable to coerce current fill_value nan to int64 dtype
164166
165167
.. _sparse.calculation:
@@ -223,10 +225,6 @@ A :meth:`SparseSeries.to_coo` method is implemented for transforming a ``SparseS
223225

224226
The method requires a ``MultiIndex`` with two or more levels.
225227

226-
.. ipython:: python
227-
:suppress:
228-
229-
230228
.. ipython:: python
231229
232230
s = pd.Series([3.0, np.nan, 1.0, 3.0, np.nan, np.nan])
@@ -271,9 +269,6 @@ Specifying different row and column labels (and not sorting them) yields a diffe
271269
272270
A convenience method :meth:`SparseSeries.from_coo` is implemented for creating a ``SparseSeries`` from a ``scipy.sparse.coo_matrix``.
273271

274-
.. ipython:: python
275-
:suppress:
276-
277272
.. ipython:: python
278273
279274
from scipy import sparse

doc/source/whatsnew/v0.13.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Enhancements
220220
221221
pd.MultiIndex.from_product([shades, colors], names=['shade', 'color'])
222222
223-
- Panel :meth:`~pandas.Panel.apply` will work on non-ufuncs. See :ref:`the docs<basics.apply_panel>`.
223+
- Panel :meth:`~pandas.Panel.apply` will work on non-ufuncs. See :ref:`the docs<basics.apply>`.
224224

225225
.. ipython:: python
226226

doc/source/whatsnew/v0.19.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,8 @@ Operators now preserve dtypes
12501250
s
12511251
s.astype(np.int64)
12521252
1253-
``astype`` fails if data contains values which cannot be converted to specified ``dtype``.
1254-
Note that the limitation is applied to ``fill_value`` which default is ``np.nan``.
1253+
``astype`` fails if data contains values which cannot be converted to specified ``dtype``.
1254+
Note that the limitation is applied to ``fill_value`` which default is ``np.nan``.
12551255

12561256
.. code-block:: ipython
12571257

pandas/io/parsers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
Also supports optionally iterating or breaking of the file
6060
into chunks.
6161
62-
Additional help can be found in the `online docs for IO Tools
63-
<http://pandas.pydata.org/pandas-docs/stable/io.html>`_.
62+
Additional help can be found in the online docs for
63+
`IO Tools <http://pandas.pydata.org/pandas-docs/stable/io.html>`_.
6464
6565
Parameters
6666
----------

0 commit comments

Comments
 (0)