Skip to content

Commit de32fc7

Browse files
PrayagSjbrockmendel
authored andcommitted
DOC: use black to fix code style in doc pandas-dev#36777 (pandas-dev#36824)
1 parent f3125ab commit de32fc7

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

doc/source/development/extending.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ decorate a class, providing the name of attribute to add. The class's
5050
5151
Now users can access your methods using the ``geo`` namespace:
5252

53-
>>> ds = pd.DataFrame({'longitude': np.linspace(0, 10),
54-
... 'latitude': np.linspace(0, 20)})
53+
>>> ds = pd.Dataframe(
54+
... {"longitude": np.linspace(0, 10), "latitude": np.linspace(0, 20)}
55+
... )
5556
>>> ds.geo.center
5657
(5.0, 10.0)
5758
>>> ds.geo.plot()
@@ -499,4 +500,4 @@ registers the default "matplotlib" backend as follows.
499500
500501
501502
More information on how to implement a third-party plotting backend can be found at
502-
https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/__init__.py#L1.
503+
https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/__init__.py#L1.

doc/source/user_guide/duplicates.rst

+15-20
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ duplicates present. The output can't be determined, and so pandas raises.
2929
.. ipython:: python
3030
:okexcept:
3131
32-
s1 = pd.Series([0, 1, 2], index=['a', 'b', 'b'])
33-
s1.reindex(['a', 'b', 'c'])
32+
s1 = pd.Series([0, 1, 2], index=["a", "b", "b"])
33+
s1.reindex(["a", "b", "c"])
3434
3535
Other methods, like indexing, can give very surprising results. Typically
3636
indexing with a scalar will *reduce dimensionality*. Slicing a ``DataFrame``
@@ -39,30 +39,30 @@ return a scalar. But with duplicates, this isn't the case.
3939

4040
.. ipython:: python
4141
42-
df1 = pd.DataFrame([[0, 1, 2], [3, 4, 5]], columns=['A', 'A', 'B'])
42+
df1 = pd.DataFrame([[0, 1, 2], [3, 4, 5]], columns=["A", "A", "B"])
4343
df1
4444
4545
We have duplicates in the columns. If we slice ``'B'``, we get back a ``Series``
4646

4747
.. ipython:: python
4848
49-
df1['B'] # a series
49+
df1["B"] # a series
5050
5151
But slicing ``'A'`` returns a ``DataFrame``
5252

5353

5454
.. ipython:: python
5555
56-
df1['A'] # a DataFrame
56+
df1["A"] # a DataFrame
5757
5858
This applies to row labels as well
5959

6060
.. ipython:: python
6161
62-
df2 = pd.DataFrame({"A": [0, 1, 2]}, index=['a', 'a', 'b'])
62+
df2 = pd.DataFrame({"A": [0, 1, 2]}, index=["a", "a", "b"])
6363
df2
64-
df2.loc['b', 'A'] # a scalar
65-
df2.loc['a', 'A'] # a Series
64+
df2.loc["b", "A"] # a scalar
65+
df2.loc["a", "A"] # a Series
6666
6767
Duplicate Label Detection
6868
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -121,29 +121,24 @@ will be raised.
121121
.. ipython:: python
122122
:okexcept:
123123
124-
pd.Series(
125-
[0, 1, 2],
126-
index=['a', 'b', 'b']
127-
).set_flags(allows_duplicate_labels=False)
124+
pd.Series([0, 1, 2], index=["a", "b", "b"]).set_flags(allows_duplicate_labels=False)
128125
129126
This applies to both row and column labels for a :class:`DataFrame`
130127

131128
.. ipython:: python
132129
:okexcept:
133130
134-
pd.DataFrame(
135-
[[0, 1, 2], [3, 4, 5]], columns=["A", "B", "C"],
136-
).set_flags(allows_duplicate_labels=False)
131+
pd.DataFrame([[0, 1, 2], [3, 4, 5]], columns=["A", "B", "C"],).set_flags(
132+
allows_duplicate_labels=False
133+
)
137134
138135
This attribute can be checked or set with :attr:`~DataFrame.flags.allows_duplicate_labels`,
139136
which indicates whether that object can have duplicate labels.
140137

141138
.. ipython:: python
142139
143-
df = (
144-
pd.DataFrame({"A": [0, 1, 2, 3]},
145-
index=['x', 'y', 'X', 'Y'])
146-
.set_flags(allows_duplicate_labels=False)
140+
df = pd.DataFrame({"A": [0, 1, 2, 3]}, index=["x", "y", "X", "Y"]).set_flags(
141+
allows_duplicate_labels=False
147142
)
148143
df
149144
df.flags.allows_duplicate_labels
@@ -198,7 +193,7 @@ operations.
198193
.. ipython:: python
199194
:okexcept:
200195
201-
s1 = pd.Series(0, index=['a', 'b']).set_flags(allows_duplicate_labels=False)
196+
s1 = pd.Series(0, index=["a", "b"]).set_flags(allows_duplicate_labels=False)
202197
s1
203198
s1.head().rename({"a": "b"})
204199

doc/source/user_guide/gotchas.rst

+17-11
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ when calling :meth:`~DataFrame.info`:
2121

2222
.. ipython:: python
2323
24-
dtypes = ['int64', 'float64', 'datetime64[ns]', 'timedelta64[ns]',
25-
'complex128', 'object', 'bool']
24+
dtypes = [
25+
"int64",
26+
"float64",
27+
"datetime64[ns]",
28+
"timedelta64[ns]",
29+
"complex128",
30+
"object",
31+
"bool",
32+
]
2633
n = 5000
2734
data = {t: np.random.randint(100, size=n).astype(t) for t in dtypes}
2835
df = pd.DataFrame(data)
29-
df['categorical'] = df['object'].astype('category')
36+
df["categorical"] = df["object"].astype("category")
3037
3138
df.info()
3239
@@ -40,7 +47,7 @@ as it can be expensive to do this deeper introspection.
4047

4148
.. ipython:: python
4249
43-
df.info(memory_usage='deep')
50+
df.info(memory_usage="deep")
4451
4552
By default the display option is set to ``True`` but can be explicitly
4653
overridden by passing the ``memory_usage`` argument when invoking ``df.info()``.
@@ -155,7 +162,7 @@ index, not membership among the values.
155162

156163
.. ipython:: python
157164
158-
s = pd.Series(range(5), index=list('abcde'))
165+
s = pd.Series(range(5), index=list("abcde"))
159166
2 in s
160167
'b' in s
161168
@@ -206,11 +213,11 @@ arrays. For example:
206213

207214
.. ipython:: python
208215
209-
s = pd.Series([1, 2, 3, 4, 5], index=list('abcde'))
216+
s = pd.Series([1, 2, 3, 4, 5], index=list("abcde"))
210217
s
211218
s.dtype
212219
213-
s2 = s.reindex(['a', 'b', 'c', 'f', 'u'])
220+
s2 = s.reindex(["a", "b", "c", "f", "u"])
214221
s2
215222
s2.dtype
216223
@@ -227,12 +234,11 @@ the nullable-integer extension dtypes provided by pandas
227234

228235
.. ipython:: python
229236
230-
s_int = pd.Series([1, 2, 3, 4, 5], index=list('abcde'),
231-
dtype=pd.Int64Dtype())
237+
s_int = pd.Series([1, 2, 3, 4, 5], index=list("abcde"), dtype=pd.Int64Dtype())
232238
s_int
233239
s_int.dtype
234240
235-
s2_int = s_int.reindex(['a', 'b', 'c', 'f', 'u'])
241+
s2_int = s_int.reindex(["a", "b", "c", "f", "u"])
236242
s2_int
237243
s2_int.dtype
238244
@@ -334,7 +340,7 @@ constructors using something similar to the following:
334340

335341
.. ipython:: python
336342
337-
x = np.array(list(range(10)), '>i4') # big endian
343+
x = np.array(list(range(10)), ">i4") # big endian
338344
newx = x.byteswap().newbyteorder() # force native byteorder
339345
s = pd.Series(newx)
340346

0 commit comments

Comments
 (0)