Skip to content

Commit fbb9601

Browse files
committed
DOC/BLD: fix annoying sphinx bugs
1 parent eb25047 commit fbb9601

File tree

6 files changed

+95
-90
lines changed

6 files changed

+95
-90
lines changed

pandas/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,8 @@ def iterpairs(seq):
13481348
-------
13491349
iterator returning overlapping pairs of elements
13501350
1351-
Example
1352-
-------
1351+
Examples
1352+
--------
13531353
>>> iterpairs([1, 2, 3, 4])
13541354
[(1, 2), (2, 3), (3, 4)
13551355
"""

pandas/core/frame.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,8 @@ def to_csv(self, path_or_buf, sep=",", na_rep='', float_format=None,
13741374
mode='w', nanRep=None, encoding=None, quoting=None,
13751375
line_terminator='\n', chunksize=None,
13761376
tupleize_cols=True, **kwds):
1377-
"""
1378-
Write DataFrame to a comma-separated values (csv) file
1379-
1377+
r"""Write DataFrame to a comma-separated values (csv) file
1378+
13801379
Parameters
13811380
----------
13821381
path_or_buf : string or file handle / StringIO
@@ -1390,8 +1389,8 @@ def to_csv(self, path_or_buf, sep=",", na_rep='', float_format=None,
13901389
cols : sequence, optional
13911390
Columns to write
13921391
header : boolean or list of string, default True
1393-
Write out column names. If a list of string is given it is
1394-
assumed to be aliases for the column names
1392+
Write out column names. If a list of string is given it is assumed
1393+
to be aliases for the column names
13951394
index : boolean, default True
13961395
Write row names (index)
13971396
index_label : string or sequence, or False, default None
@@ -1400,21 +1399,23 @@ def to_csv(self, path_or_buf, sep=",", na_rep='', float_format=None,
14001399
sequence should be given if the DataFrame uses MultiIndex. If
14011400
False do not print fields for index names. Use index_label=False
14021401
for easier importing in R
1403-
nanRep : deprecated, use na_rep
1404-
mode : Python write mode, default 'w'
1402+
nanRep : None
1403+
deprecated, use na_rep
1404+
mode : str
1405+
Python write mode, default 'w'
14051406
encoding : string, optional
14061407
a string representing the encoding to use if the contents are
14071408
non-ascii, for python versions prior to 3
1408-
line_terminator: string, default '\n'
1409+
line_terminator : string, default '\\n'
14091410
The newline character or character sequence to use in the output
14101411
file
14111412
quoting : optional constant from csv module
14121413
defaults to csv.QUOTE_MINIMAL
1413-
chunksize : rows to write at a time
1414+
chunksize : int or None
1415+
rows to write at a time
14141416
tupleize_cols : boolean, default True
14151417
write multi_index columns as a list of tuples (if True)
14161418
or new (expanded format) if False)
1417-
14181419
"""
14191420
if nanRep is not None: # pragma: no cover
14201421
import warnings
@@ -2401,27 +2402,31 @@ def xs(self, key, axis=0, level=None, copy=True):
24012402
_xs = xs
24022403

24032404
def lookup(self, row_labels, col_labels):
2404-
"""
2405-
Label-based "fancy indexing" function for DataFrame. Given equal-length
2406-
arrays of row and column labels, return an array of the values
2407-
corresponding to each (row, col) pair.
2405+
"""Label-based "fancy indexing" function for DataFrame. Given
2406+
equal-length arrays of row and column labels, return an array of the
2407+
values corresponding to each (row, col) pair.
24082408
24092409
Parameters
24102410
----------
24112411
row_labels : sequence
2412+
The row labels to use for lookup
24122413
col_labels : sequence
2414+
The column labels to use for lookup
24132415
24142416
Notes
24152417
-----
24162418
Akin to
24172419
2418-
result = []
2419-
for row, col in zip(row_labels, col_labels):
2420-
result.append(df.get_value(row, col))
2420+
.. code-block:: python
24212421
2422-
Example
2423-
-------
2422+
result = []
2423+
for row, col in zip(row_labels, col_labels):
2424+
result.append(df.get_value(row, col))
2425+
2426+
Examples
2427+
--------
24242428
values : ndarray
2429+
The found values
24252430
24262431
"""
24272432
from itertools import izip
@@ -3483,20 +3488,26 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
34833488
Parameters
34843489
----------
34853490
to_replace : str, regex, list, dict, Series, numeric, or None
3491+
34863492
* str or regex:
3493+
34873494
- str: string exactly matching `to_replace` will be replaced
34883495
with `value`
34893496
- regex: regexs matching `to_replace` will be replaced with
34903497
`value`
3498+
34913499
* list of str, regex, or numeric:
3500+
34923501
- First, if `to_replace` and `value` are both lists, they
34933502
**must** be the same length.
34943503
- Second, if ``regex=True`` then all of the strings in **both**
34953504
lists will be interpreted as regexs otherwise they will match
34963505
directly. This doesn't matter much for `value` since there
34973506
are only a few possible substitution regexes you can use.
34983507
- str and regex rules apply as above.
3508+
34993509
* dict:
3510+
35003511
- Nested dictionaries, e.g., {'a': {'b': nan}}, are read as
35013512
follows: look in column 'a' for the value 'b' and replace it
35023513
with nan. You can nest regular expressions as well. Note that
@@ -3505,11 +3516,14 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
35053516
- Keys map to column names and values map to substitution
35063517
values. You can treat this as a special case of passing two
35073518
lists except that you are specifying the column to search in.
3519+
35083520
* None:
3521+
35093522
- This means that the ``regex`` argument must be a string,
35103523
compiled regular expression, or list, dict, ndarray or Series
35113524
of such elements. If `value` is also ``None`` then this
35123525
**must** be a nested dictionary or ``Series``.
3526+
35133527
See the examples section for examples of each of these.
35143528
value : scalar, dict, list, str, regex, default None
35153529
Value to use to fill holes (e.g. 0), alternately a dict of values

pandas/core/groupby.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,8 @@ def aggregate(self, func_or_funcs, *args, **kwargs):
13741374
-----
13751375
agg is an alias for aggregate. Use it.
13761376
1377-
Example
1378-
-------
1377+
Examples
1378+
--------
13791379
>>> series
13801380
bar 1.0
13811381
baz 2.0
@@ -1523,8 +1523,8 @@ def transform(self, func, *args, **kwargs):
15231523
func : function
15241524
To apply to each group. Should return a Series with the same index
15251525
1526-
Example
1527-
-------
1526+
Examples
1527+
--------
15281528
>>> grouped.transform(lambda x: (x - x.mean()) / x.std())
15291529
15301530
Returns
@@ -1906,7 +1906,7 @@ def transform(self, func, *args, **kwargs):
19061906
Each subframe is endowed the attribute 'name' in case you need to know
19071907
which group you are working on.
19081908
1909-
Example
1909+
Examples
19101910
--------
19111911
>>> grouped = df.groupby(lambda x: mapping[x])
19121912
>>> grouped.transform(lambda x: (x - x.mean()) / x.std())

pandas/io/excel.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from itertools import izip
1010
import numpy as np
1111

12-
from pandas.core.index import Index, MultiIndex
13-
from pandas.core.frame import DataFrame
14-
import pandas.core.common as com
15-
from pandas.util import py3compat
1612
from pandas.io.parsers import TextParser
1713
from pandas.tseries.period import Period
1814
import json
@@ -21,8 +17,7 @@ def read_excel(path_or_buf, sheetname, header=0, skiprows=None, skip_footer=0,
2117
index_col=None, parse_cols=None, parse_dates=False,
2218
date_parser=None, na_values=None, thousands=None, chunksize=None,
2319
kind=None, **kwds):
24-
"""
25-
Read Excel table into DataFrame
20+
"""Read an Excel table into a pandas DataFrame
2621
2722
Parameters
2823
----------
@@ -38,23 +33,30 @@ def read_excel(path_or_buf, sheetname, header=0, skiprows=None, skip_footer=0,
3833
Column to use as the row labels of the DataFrame. Pass None if
3934
there is no such column
4035
parse_cols : int or list, default None
41-
If None then parse all columns,
42-
If int then indicates last column to be parsed
43-
If list of ints then indicates list of column numbers to be parsed
44-
If string then indicates comma separated list of column names and
45-
column ranges (e.g. "A:E" or "A,C,E:F")
36+
* If None then parse all columns,
37+
* If int then indicates last column to be parsed
38+
* If list of ints then indicates list of column numbers to be parsed
39+
* If string then indicates comma separated list of column names and
40+
column ranges (e.g. "A:E" or "A,C,E:F")
4641
na_values : list-like, default None
4742
List of additional strings to recognize as NA/NaN
4843
4944
Returns
5045
-------
5146
parsed : DataFrame
47+
DataFrame from the passed in Excel file
5248
"""
5349
return ExcelFile(path_or_buf,kind=kind).parse(sheetname=sheetname,
54-
header=0, skiprows=None, skip_footer=0,
55-
index_col=None, parse_cols=None, parse_dates=False,
56-
date_parser=None, na_values=None, thousands=None, chunksize=None,
57-
kind=None, **kwds)
50+
header=0, skiprows=None,
51+
skip_footer=0,
52+
index_col=None,
53+
parse_cols=None,
54+
parse_dates=False,
55+
date_parser=None,
56+
na_values=None,
57+
thousands=None,
58+
chunksize=None, kind=None,
59+
**kwds)
5860

5961
class ExcelFile(object):
6062
"""
@@ -90,8 +92,7 @@ def parse(self, sheetname, header=0, skiprows=None, skip_footer=0,
9092
index_col=None, parse_cols=None, parse_dates=False,
9193
date_parser=None, na_values=None, thousands=None, chunksize=None,
9294
**kwds):
93-
"""
94-
Read Excel table into DataFrame
95+
"""Read an Excel table into DataFrame
9596
9697
Parameters
9798
----------
@@ -107,17 +108,19 @@ def parse(self, sheetname, header=0, skiprows=None, skip_footer=0,
107108
Column to use as the row labels of the DataFrame. Pass None if
108109
there is no such column
109110
parse_cols : int or list, default None
110-
If None then parse all columns,
111-
If int then indicates last column to be parsed
112-
If list of ints then indicates list of column numbers to be parsed
113-
If string then indicates comma separated list of column names and
114-
column ranges (e.g. "A:E" or "A,C,E:F")
111+
* If None then parse all columns
112+
* If int then indicates last column to be parsed
113+
* If list of ints then indicates list of column numbers to be
114+
parsed
115+
* If string then indicates comma separated list of column names and
116+
column ranges (e.g. "A:E" or "A,C,E:F")
115117
na_values : list-like, default None
116118
List of additional strings to recognize as NA/NaN
117119
118120
Returns
119121
-------
120122
parsed : DataFrame
123+
DataFrame parsed from the Excel file
121124
"""
122125

123126
# has_index_names: boolean, default False

pandas/io/pytables.py

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,6 @@ def select(self, key, where=None, start=None, stop=None, columns=None, iterator=
386386
Parameters
387387
----------
388388
key : object
389-
390-
Optional Parameters
391-
-------------------
392389
where : list of Term (or convertable) objects, optional
393390
start : integer (defaults to None), row number to start selection
394391
stop : integer (defaults to None), row number to stop selection
@@ -421,9 +418,6 @@ def select_as_coordinates(self, key, where=None, start=None, stop=None, **kwargs
421418
Parameters
422419
----------
423420
key : object
424-
425-
Optional Parameters
426-
-------------------
427421
where : list of Term (or convertable) objects, optional
428422
start : integer (defaults to None), row number to start selection
429423
stop : integer (defaults to None), row number to stop selection
@@ -551,9 +545,6 @@ def remove(self, key, where=None, start=None, stop=None):
551545
----------
552546
key : string
553547
Node to remove or delete rows from
554-
555-
Optional Parameters
556-
-------------------
557548
where : list of Term (or convertable) objects, optional
558549
start : integer (defaults to None), row number to start selection
559550
stop : integer (defaults to None), row number to stop selection
@@ -602,9 +593,6 @@ def append(self, key, value, columns=None, **kwargs):
602593
----------
603594
key : object
604595
value : {Series, DataFrame, Panel, Panel4D}
605-
606-
Optional Parameters
607-
-------------------
608596
data_columns : list of columns to create as data columns, or True to use all columns
609597
min_itemsize : dict of columns that specify minimum string sizes
610598
nan_rep : string to use as string nan represenation
@@ -3276,30 +3264,29 @@ def _need_convert(kind):
32763264
return False
32773265

32783266
class Term(object):
3279-
""" create a term object that holds a field, op, and value
3267+
"""create a term object that holds a field, op, and value
32803268
3281-
Parameters
3282-
----------
3283-
field : dict, string term expression, or the field to operate (must be a valid index/column type of DataFrame/Panel)
3284-
op : a valid op (defaults to '=') (optional)
3285-
>, >=, <, <=, =, != (not equal) are allowed
3286-
value : a value or list of values (required)
3287-
queryables : a kinds map (dict of column name -> kind), or None i column is non-indexable
3269+
Parameters
3270+
----------
3271+
field : dict, string term expression, or the field to operate (must be a valid index/column type of DataFrame/Panel)
3272+
op : a valid op (defaults to '=') (optional)
3273+
>, >=, <, <=, =, != (not equal) are allowed
3274+
value : a value or list of values (required)
3275+
queryables : a kinds map (dict of column name -> kind), or None i column is non-indexable
32883276
3289-
Returns
3290-
-------
3291-
a Term object
3292-
3293-
Examples
3294-
--------
3295-
Term(dict(field = 'index', op = '>', value = '20121114'))
3296-
Term('index', '20121114')
3297-
Term('index', '>', '20121114')
3298-
Term('index', ['20121114','20121114'])
3299-
Term('index', datetime(2012,11,14))
3300-
Term('major_axis>20121114')
3301-
Term('minor_axis', ['A','B'])
3277+
Returns
3278+
-------
3279+
a Term object
33023280
3281+
Examples
3282+
--------
3283+
>>> Term(dict(field = 'index', op = '>', value = '20121114'))
3284+
>>> Term('index', '20121114')
3285+
>>> Term('index', '>', '20121114')
3286+
>>> Term('index', ['20121114','20121114'])
3287+
>>> Term('index', datetime(2012,11,14))
3288+
>>> Term('major_axis>20121114')
3289+
>>> Term('minor_axis', ['A','B'])
33033290
"""
33043291

33053292
_ops = ['<=', '<', '>=', '>', '!=', '==', '=']

0 commit comments

Comments
 (0)