Skip to content

Commit 0f76a2a

Browse files
committed
DOC: Fix code block line length
1 parent 86f5431 commit 0f76a2a

File tree

6 files changed

+130
-26
lines changed

6 files changed

+130
-26
lines changed

doc/source/user_guide/categorical.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,11 @@ The ordering of the categorical is determined by the ``categories`` of that colu
513513
514514
dfs = pd.DataFrame(
515515
{
516-
"A": pd.Categorical(list("bbeebbaa"), categories=["e", "a", "b"], ordered=True),
516+
"A": pd.Categorical(
517+
list("bbeebbaa"),
518+
categories=["e", "a", "b"],
519+
ordered=True,
520+
),
517521
"B": [1, 2, 1, 2, 2, 1, 2, 1],
518522
}
519523
)
@@ -642,7 +646,13 @@ Groupby will also show "unused" categories:
642646
df.groupby("cats").mean()
643647
644648
cats2 = pd.Categorical(["a", "a", "b", "b"], categories=["a", "b", "c"])
645-
df2 = pd.DataFrame({"cats": cats2, "B": ["c", "d", "c", "d"], "values": [1, 2, 3, 4]})
649+
df2 = pd.DataFrame(
650+
{
651+
"cats": cats2,
652+
"B": ["c", "d", "c", "d"],
653+
"values": [1, 2, 3, 4],
654+
}
655+
)
646656
df2.groupby(["cats", "B"]).mean()
647657
648658
@@ -1115,7 +1125,11 @@ You can use ``fillna`` to handle missing values before applying a function.
11151125
.. ipython:: python
11161126
11171127
df = pd.DataFrame(
1118-
{"a": [1, 2, 3, 4], "b": ["a", "b", "c", "d"], "cats": pd.Categorical([1, 2, 3, 2])}
1128+
{
1129+
"a": [1, 2, 3, 4],
1130+
"b": ["a", "b", "c", "d"],
1131+
"cats": pd.Categorical([1, 2, 3, 2])
1132+
}
11191133
)
11201134
df.apply(lambda row: type(row["cats"]), axis=1)
11211135
df.apply(lambda col: col.dtype, axis=0)

doc/source/user_guide/io.rst

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,12 @@ Note that ``infer_datetime_format`` is sensitive to ``dayfirst``. With
986986
.. ipython:: python
987987
988988
# Try to infer the format for the index column
989-
df = pd.read_csv("foo.csv", index_col=0, parse_dates=True, infer_datetime_format=True)
989+
df = pd.read_csv(
990+
"foo.csv",
991+
index_col=0,
992+
parse_dates=True,
993+
infer_datetime_format=True,
994+
)
990995
df
991996
992997
.. ipython:: python
@@ -1046,9 +1051,19 @@ writing to a file). For example:
10461051
10471052
val = "0.3066101993807095471566981359501369297504425048828125"
10481053
data = "a,b,c\n1,2,{0}".format(val)
1049-
abs(pd.read_csv(StringIO(data), engine="c", float_precision=None)["c"][0] - float(val))
10501054
abs(
1051-
pd.read_csv(StringIO(data), engine="c", float_precision="high")["c"][0] - float(val)
1055+
pd.read_csv(
1056+
StringIO(data),
1057+
engine="c",
1058+
float_precision=None
1059+
)["c"][0] - float(val)
1060+
)
1061+
abs(
1062+
pd.read_csv(
1063+
StringIO(data),
1064+
engine="c",
1065+
float_precision="high"
1066+
)["c"][0] - float(val)
10521067
)
10531068
abs(
10541069
pd.read_csv(StringIO(data), engine="c", float_precision="round_trip")["c"][0]
@@ -2517,7 +2532,12 @@ columns to strings.
25172532
.. code-block:: python
25182533
25192534
url_mcc = "https://en.wikipedia.org/wiki/Mobile_country_code"
2520-
dfs = pd.read_html(url_mcc, match="Telekom Albania", header=0, converters={"MNC": str})
2535+
dfs = pd.read_html(
2536+
url_mcc,
2537+
match="Telekom Albania",
2538+
header=0,
2539+
converters={"MNC": str},
2540+
)
25212541
25222542
Use some combination of the above:
25232543

@@ -3570,7 +3590,12 @@ HDFStore will by default not drop rows that are all missing. This behavior can b
35703590

35713591
.. ipython:: python
35723592
3573-
df_with_missing = pd.DataFrame({"col1": [0, np.nan, 2], "col2": [1, np.nan, np.nan]})
3593+
df_with_missing = pd.DataFrame(
3594+
{
3595+
"col1": [0, np.nan, 2],
3596+
"col2": [1, np.nan, np.nan]
3597+
}
3598+
)
35743599
df_with_missing
35753600
35763601
df_with_missing.to_hdf("file.h5", "df_with_missing", format="table", mode="w")
@@ -3944,7 +3969,8 @@ specified in the format: ``<float>(<unit>)``, where float may be signed (and fra
39443969
{
39453970
"A": pd.Timestamp("20130101"),
39463971
"B": [
3947-
pd.Timestamp("20130101") + timedelta(days=i, seconds=10) for i in range(10)
3972+
pd.Timestamp("20130101") + timedelta(days=i, seconds=10)
3973+
for i in range(10)
39483974
],
39493975
}
39503976
)
@@ -4241,7 +4267,11 @@ results.
42414267
store.select("df2_mt")
42424268
42434269
# as a multiple
4244-
store.select_as_multiple(["df1_mt", "df2_mt"], where=["A>0", "B>0"], selector="df1_mt")
4270+
store.select_as_multiple(
4271+
["df1_mt", "df2_mt"],
4272+
where=["A>0", "B>0"],
4273+
selector="df1_mt",
4274+
)
42454275
42464276
42474277
Delete from a table
@@ -4797,8 +4827,16 @@ Read only certain columns of a parquet file.
47974827

47984828
.. ipython:: python
47994829
4800-
result = pd.read_parquet("example_fp.parquet", engine="fastparquet", columns=["a", "b"])
4801-
result = pd.read_parquet("example_pa.parquet", engine="pyarrow", columns=["a", "b"])
4830+
result = pd.read_parquet(
4831+
"example_fp.parquet",
4832+
engine="fastparquet",
4833+
columns=["a", "b"],
4834+
)
4835+
result = pd.read_parquet(
4836+
"example_pa.parquet",
4837+
engine="pyarrow",
4838+
columns=["a", "b"],
4839+
)
48024840
result.dtypes
48034841
48044842
@@ -5176,7 +5214,11 @@ to pass to :func:`pandas.to_datetime`:
51765214
.. code-block:: python
51775215
51785216
pd.read_sql_table("data", engine, parse_dates={"Date": "%Y-%m-%d"})
5179-
pd.read_sql_table("data", engine, parse_dates={"Date": {"format": "%Y-%m-%d %H:%M:%S"}})
5217+
pd.read_sql_table(
5218+
"data",
5219+
engine,
5220+
parse_dates={"Date": {"format": "%Y-%m-%d %H:%M:%S"}},
5221+
)
51805222
51815223
51825224
You can check if a table exists using :func:`~pandas.io.sql.has_table`
@@ -5593,7 +5635,11 @@ avoid converting categorical columns into ``pd.Categorical``:
55935635

55945636
.. code-block:: python
55955637
5596-
df = pd.read_spss("spss_data.sav", usecols=["foo", "bar"], convert_categoricals=False)
5638+
df = pd.read_spss(
5639+
"spss_data.sav",
5640+
usecols=["foo", "bar"],
5641+
convert_categoricals=False,
5642+
)
55975643
55985644
More information about the SAV and ZSAV file formats is available here_.
55995645

doc/source/user_guide/reshaping.rst

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,13 @@ calling ``sort_index``, of course). Here is a more complex example:
238238
.. ipython:: python
239239
240240
columns = pd.MultiIndex.from_tuples(
241-
[("A", "cat"), ("B", "dog"), ("B", "cat"), ("A", "dog")], names=["exp", "animal"]
241+
[
242+
("A", "cat"),
243+
("B", "dog"),
244+
("B", "cat"),
245+
("A", "dog"),
246+
],
247+
names=["exp", "animal"],
242248
)
243249
index = pd.MultiIndex.from_product(
244250
[("bar", "baz", "foo", "qux"), ("one", "two")], names=["first", "second"]
@@ -800,14 +806,26 @@ parameter.
800806

801807
.. ipython:: python
802808
803-
df.pivot_table(values="val0", index="row", columns="col", aggfunc="mean", fill_value=0)
809+
df.pivot_table(
810+
values="val0",
811+
index="row",
812+
columns="col",
813+
aggfunc="mean",
814+
fill_value=0,
815+
)
804816
805817
Also note that we can pass in other aggregation functions as well. For example,
806818
we can also pass in ``sum``.
807819

808820
.. ipython:: python
809821
810-
df.pivot_table(values="val0", index="row", columns="col", aggfunc="sum", fill_value=0)
822+
df.pivot_table(
823+
values="val0",
824+
index="row",
825+
columns="col",
826+
aggfunc="sum",
827+
fill_value=0,
828+
)
811829
812830
Another aggregation we can do is calculate the frequency in which the columns
813831
and rows occur together a.k.a. "cross tabulation". To do this, we can pass
@@ -825,7 +843,12 @@ We can also perform multiple aggregations. For example, to perform both a
825843

826844
.. ipython:: python
827845
828-
df.pivot_table(values="val0", index="row", columns="col", aggfunc=["mean", "sum"])
846+
df.pivot_table(
847+
values="val0",
848+
index="row",
849+
columns="col",
850+
aggfunc=["mean", "sum"],
851+
)
829852
830853
Note to aggregate over multiple value columns, we can pass in a list to the
831854
``values`` parameter.
@@ -839,7 +862,12 @@ Note to subdivide over multiple columns we can pass in a list to the
839862

840863
.. ipython:: python
841864
842-
df.pivot_table(values=["val0"], index="row", columns=["item", "col"], aggfunc=["mean"])
865+
df.pivot_table(
866+
values=["val0"],
867+
index="row",
868+
columns=["item", "col"],
869+
aggfunc=["mean"],
870+
)
843871
844872
.. _reshaping.explode:
845873

doc/source/user_guide/text.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ i.e., from the end of the string to the beginning of the string:
261261
.. ipython:: python
262262
263263
s3 = pd.Series(
264-
["A", "B", "C", "Aaba", "Baca", "", np.nan, "CABA", "dog", "cat"], dtype="string"
264+
["A", "B", "C", "Aaba", "Baca", "", np.nan, "CABA", "dog", "cat"],
265+
dtype="string",
265266
)
266267
s3
267268
s3.str.replace("^.a|dog", "XX-XX ", case=False)
@@ -515,7 +516,10 @@ DataFrame with one column per group.
515516

516517
.. ipython:: python
517518
518-
pd.Series(["a1", "b2", "c3"], dtype="string").str.extract(r"([ab])(\d)", expand=False)
519+
pd.Series(
520+
["a1", "b2", "c3"],
521+
dtype="string",
522+
).str.extract(r"([ab])(\d)", expand=False)
519523
520524
Elements that do not match return a row filled with ``NaN``. Thus, a
521525
Series of messy strings can be "converted" into a like-indexed Series
@@ -536,7 +540,10 @@ and optional groups like
536540

537541
.. ipython:: python
538542
539-
pd.Series(["a1", "b2", "3"], dtype="string").str.extract(r"([ab])?(\d)", expand=False)
543+
pd.Series(
544+
["a1", "b2", "3"],
545+
dtype="string",
546+
).str.extract(r"([ab])?(\d)", expand=False)
540547
541548
can also be used. Note that any capture group names in the regular
542549
expression will be used for column names; otherwise capture group
@@ -661,13 +668,19 @@ Or whether elements match a pattern:
661668

662669
.. ipython:: python
663670
664-
pd.Series(["1", "2", "3a", "3b", "03c", "4dx"], dtype="string").str.match(pattern)
671+
pd.Series(
672+
["1", "2", "3a", "3b", "03c", "4dx"],
673+
dtype="string",
674+
).str.match(pattern)
665675
666676
.. versionadded:: 1.1.0
667677

668678
.. ipython:: python
669679
670-
pd.Series(["1", "2", "3a", "3b", "03c", "4dx"], dtype="string").str.fullmatch(pattern)
680+
pd.Series(
681+
["1", "2", "3a", "3b", "03c", "4dx"],
682+
dtype="string",
683+
).str.fullmatch(pattern)
671684
672685
.. note::
673686

doc/source/user_guide/timedeltas.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,10 @@ Similarly to other of the datetime-like indices, ``DatetimeIndex`` and ``PeriodI
409409

410410
.. ipython:: python
411411
412-
s = pd.Series(np.arange(100), index=pd.timedelta_range("1 days", periods=100, freq="h"))
412+
s = pd.Series(
413+
np.arange(100),
414+
index=pd.timedelta_range("1 days", periods=100, freq="h"),
415+
)
413416
s
414417
415418
Selections work similarly, with coercion on string-likes and slices:

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exclude =
3333
env # exclude asv benchmark environments from linting
3434

3535
[flake8-rst]
36-
max-line-length = 88
36+
max-line-length = 84
3737
bootstrap =
3838
import numpy as np
3939
import pandas as pd

0 commit comments

Comments
 (0)