Skip to content

Commit 6588999

Browse files
committed
Format all rst files
1 parent 27e081b commit 6588999

Some content is hidden

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

60 files changed

+965
-767
lines changed

doc/source/development/contributing_codebase.rst

+21-9
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ The appropriate way to annotate this would be as follows
179179
180180
str_type = str
181181
182+
182183
class SomeClass2:
183184
str: str_type = None
184185
@@ -190,8 +191,8 @@ In some cases you may be tempted to use ``cast`` from the typing module when you
190191
191192
from pandas.core.dtypes.common import is_number
192193
193-
def cannot_infer_bad(obj: Union[str, int, float]):
194194
195+
def cannot_infer_bad(obj: Union[str, int, float]):
195196
if is_number(obj):
196197
...
197198
else: # Reasonably only str objects would reach this but...
@@ -203,7 +204,6 @@ The limitation here is that while a human can reasonably understand that ``is_nu
203204
.. code-block:: python
204205
205206
def cannot_infer_good(obj: Union[str, int, float]):
206-
207207
if isinstance(obj, str):
208208
return obj.upper()
209209
else:
@@ -222,6 +222,7 @@ For example, quite a few functions in pandas accept a ``dtype`` argument. This c
222222
223223
from pandas._typing import Dtype
224224
225+
225226
def as_type(dtype: Dtype) -> ...:
226227
...
227228
@@ -428,6 +429,7 @@ be located.
428429
import pandas as pd
429430
import pandas._testing as tm
430431
432+
431433
def test_getitem_listlike_of_ints():
432434
ser = pd.Series(range(5))
433435
@@ -641,9 +643,13 @@ as a comment to a new test.
641643
642644
643645
@pytest.mark.parametrize(
644-
'dtype', ['float32', pytest.param('int16', marks=pytest.mark.skip),
645-
pytest.param('int32', marks=pytest.mark.xfail(
646-
reason='to show how it works'))])
646+
'dtype',
647+
[
648+
'float32',
649+
pytest.param('int16', marks=pytest.mark.skip),
650+
pytest.param('int32', marks=pytest.mark.xfail(reason='to show how it works')),
651+
],
652+
)
647653
def test_mark(dtype):
648654
assert str(np.dtype(dtype)) == 'float32'
649655
@@ -722,10 +728,16 @@ for details <https://hypothesis.readthedocs.io/en/latest/index.html>`_.
722728
import json
723729
from hypothesis import given, strategies as st
724730
725-
any_json_value = st.deferred(lambda: st.one_of(
726-
st.none(), st.booleans(), st.floats(allow_nan=False), st.text(),
727-
st.lists(any_json_value), st.dictionaries(st.text(), any_json_value)
728-
))
731+
any_json_value = st.deferred(
732+
lambda: st.one_of(
733+
st.none(),
734+
st.booleans(),
735+
st.floats(allow_nan=False),
736+
st.text(),
737+
st.lists(any_json_value),
738+
st.dictionaries(st.text(), any_json_value),
739+
)
740+
)
729741
730742
731743
@given(value=any_json_value)

doc/source/development/contributing_docstring.rst

+2-6
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ backticks. The following are considered inline code:
137137
.. code-block:: python
138138
139139
def func():
140-
141140
"""Some function.
142141
143142
With several mistakes in the docstring.
@@ -463,6 +462,7 @@ With more than one value:
463462
464463
import string
465464
465+
466466
def random_letters():
467467
"""
468468
Generate and return a sequence of random letters.
@@ -478,8 +478,7 @@ With more than one value:
478478
String of random letters.
479479
"""
480480
length = np.random.randint(1, 10)
481-
letters = ''.join(np.random.choice(string.ascii_lowercase)
482-
for i in range(length))
481+
letters = ''.join(np.random.choice(string.ascii_lowercase) for i in range(length))
483482
return length, letters
484483
485484
If the method yields its value:
@@ -628,7 +627,6 @@ A simple example could be:
628627
.. code-block:: python
629628
630629
class Series:
631-
632630
def head(self, n=5):
633631
"""
634632
Return the first elements of the Series.
@@ -724,7 +722,6 @@ positional arguments ``head(3)``.
724722
.. code-block:: python
725723
726724
class Series:
727-
728725
def mean(self):
729726
"""
730727
Compute the mean of the input.
@@ -737,7 +734,6 @@ positional arguments ``head(3)``.
737734
"""
738735
pass
739736
740-
741737
def fillna(self, value):
742738
"""
743739
Replace missing values by ``value``.

doc/source/development/extending.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ Below is an example to define two original properties, "internal_cache" as a tem
408408
.. code-block:: python
409409
410410
class SubclassedDataFrame2(pd.DataFrame):
411-
412411
# temporary properties
413412
_internal_names = pd.DataFrame._internal_names + ["internal_cache"]
414413
_internal_names_set = set(_internal_names)
@@ -526,6 +525,7 @@ The ``__pandas_priority__`` of :class:`DataFrame`, :class:`Series`, and :class:`
526525
# return `self` and not the addition for simplicity
527526
return self
528527
528+
529529
custom = CustomList()
530530
series = pd.Series([1, 2, 3])
531531

doc/source/development/maintaining.rst

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ create a file ``t.py`` in your pandas directory, which contains
144144
.. code-block:: python
145145
146146
import pandas as pd
147+
147148
assert pd.Series([1, 1]).sum() == 2
148149
149150
and then run::

doc/source/getting_started/comparison/comparison_with_spreadsheets.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ The equivalent in pandas:
427427

428428
.. ipython:: python
429429
430-
pd.pivot_table(
431-
tips, values="tip", index=["size"], columns=["sex"], aggfunc=np.average
432-
)
430+
pd.pivot_table(tips, values="tip", index=["size"], columns=["sex"], aggfunc=np.average)
433431
434432
435433
Adding a row
@@ -440,8 +438,9 @@ Assuming we are using a :class:`~pandas.RangeIndex` (numbered ``0``, ``1``, etc.
440438
.. ipython:: python
441439
442440
df
443-
new_row = pd.DataFrame([["E", 51, True]],
444-
columns=["class", "student_count", "all_pass"])
441+
new_row = pd.DataFrame(
442+
[["E", 51, True]], columns=["class", "student_count", "all_pass"]
443+
)
445444
pd.concat([df, new_row])
446445
447446

doc/source/getting_started/comparison/comparison_with_sql.rst

+3-9
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,7 @@ UNION
331331
df1 = pd.DataFrame(
332332
{"city": ["Chicago", "San Francisco", "New York City"], "rank": range(1, 4)}
333333
)
334-
df2 = pd.DataFrame(
335-
{"city": ["Chicago", "Boston", "Los Angeles"], "rank": [1, 4, 5]}
336-
)
334+
df2 = pd.DataFrame({"city": ["Chicago", "Boston", "Los Angeles"], "rank": [1, 4, 5]})
337335
338336
.. code-block:: sql
339337
@@ -433,9 +431,7 @@ Top n rows per group
433431
434432
(
435433
tips.assign(
436-
rn=tips.sort_values(["total_bill"], ascending=False)
437-
.groupby(["day"])
438-
.cumcount()
434+
rn=tips.sort_values(["total_bill"], ascending=False).groupby(["day"]).cumcount()
439435
+ 1
440436
)
441437
.query("rn < 3")
@@ -448,9 +444,7 @@ the same using ``rank(method='first')`` function
448444
449445
(
450446
tips.assign(
451-
rnk=tips.groupby(["day"])["total_bill"].rank(
452-
method="first", ascending=False
453-
)
447+
rnk=tips.groupby(["day"])["total_bill"].rank(method="first", ascending=False)
454448
)
455449
.query("rnk < 3")
456450
.sort_values(["day", "rnk"])

doc/source/getting_started/comparison/includes/time_date.rst

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
tips["date1_year"] = tips["date1"].dt.year
66
tips["date2_month"] = tips["date2"].dt.month
77
tips["date1_next"] = tips["date1"] + pd.offsets.MonthBegin()
8-
tips["months_between"] = tips["date2"].dt.to_period("M") - tips[
9-
"date1"
10-
].dt.to_period("M")
8+
tips["months_between"] = tips["date2"].dt.to_period("M") - tips["date1"].dt.to_period(
9+
"M"
10+
)
1111
12-
tips[
13-
["date1", "date2", "date1_year", "date2_month", "date1_next", "months_between"]
14-
]
12+
tips[["date1", "date2", "date1_year", "date2_month", "date1_next", "months_between"]]
1513
1614
.. ipython:: python
1715
:suppress:

doc/source/getting_started/install.rst

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ obtain these directories with.
108108
.. code-block:: python
109109
110110
import sys
111+
111112
sys.path
112113
113114
One way you could be encountering this error is if you have multiple Python installations on your system

doc/source/getting_started/intro_tutorials/08_combine_dataframes.rst

+7-10
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ Westminster* in respectively Paris, Antwerp and London.
4040

4141
.. ipython:: python
4242
43-
air_quality_no2 = pd.read_csv("data/air_quality_no2_long.csv",
44-
parse_dates=True)
45-
air_quality_no2 = air_quality_no2[["date.utc", "location",
46-
"parameter", "value"]]
43+
air_quality_no2 = pd.read_csv("data/air_quality_no2_long.csv", parse_dates=True)
44+
air_quality_no2 = air_quality_no2[["date.utc", "location", "parameter", "value"]]
4745
air_quality_no2.head()
4846
4947
.. raw:: html
@@ -75,10 +73,8 @@ Westminster* in respectively Paris, Antwerp and London.
7573

7674
.. ipython:: python
7775
78-
air_quality_pm25 = pd.read_csv("data/air_quality_pm25_long.csv",
79-
parse_dates=True)
80-
air_quality_pm25 = air_quality_pm25[["date.utc", "location",
81-
"parameter", "value"]]
76+
air_quality_pm25 = pd.read_csv("data/air_quality_pm25_long.csv", parse_dates=True)
77+
air_quality_pm25 = air_quality_pm25[["date.utc", "location", "parameter", "value"]]
8278
air_quality_pm25.head()
8379
8480
.. raw:: html
@@ -265,8 +261,9 @@ Add the parameters' full description and name, provided by the parameters metada
265261
266262
.. ipython:: python
267263
268-
air_quality = pd.merge(air_quality, air_quality_parameters,
269-
how='left', left_on='parameter', right_on='id')
264+
air_quality = pd.merge(
265+
air_quality, air_quality_parameters, how='left', left_on='parameter', right_on='id'
266+
)
270267
air_quality.head()
271268
272269
Compared to the previous example, there is no common column name.

doc/source/getting_started/intro_tutorials/09_timeseries.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ What is the average :math:`NO_2` concentration for each day of the week for each
174174

175175
.. ipython:: python
176176
177-
air_quality.groupby(
178-
[air_quality["datetime"].dt.weekday, "location"])["value"].mean()
177+
air_quality.groupby([air_quality["datetime"].dt.weekday, "location"])["value"].mean()
179178
180179
Remember the split-apply-combine pattern provided by ``groupby`` from the
181180
:ref:`tutorial on statistics calculation <10min_tut_06_stats>`?

doc/source/user_guide/10min.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ Stack
550550
.. ipython:: python
551551
552552
arrays = [
553-
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
554-
["one", "two", "one", "two", "one", "two", "one", "two"],
553+
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
554+
["one", "two", "one", "two", "one", "two", "one", "two"],
555555
]
556556
index = pd.MultiIndex.from_arrays(arrays, names=["first", "second"])
557557
df = pd.DataFrame(np.random.randn(8, 2), index=index, columns=["A", "B"])

doc/source/user_guide/advanced.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,7 @@ values **not** in the categories, similarly to how you can reindex **any** panda
792792

793793
.. ipython:: python
794794
795-
df3 = pd.DataFrame(
796-
{"A": np.arange(3), "B": pd.Series(list("abc")).astype("category")}
797-
)
795+
df3 = pd.DataFrame({"A": np.arange(3), "B": pd.Series(list("abc")).astype("category")})
798796
df3 = df3.set_index("B")
799797
df3
800798
@@ -1096,7 +1094,7 @@ index can be somewhat complicated. For example, the following does not work:
10961094
.. ipython:: python
10971095
:okexcept:
10981096
1099-
s.loc['c':'e' + 1]
1097+
s.loc['c' : 'e' + 1]
11001098
11011099
A very common use case is to limit a time series to start and end at two
11021100
specific dates. To enable this, we made the design choice to make label-based

0 commit comments

Comments
 (0)