Skip to content

Commit 85d1d02

Browse files
authored
DOC: update code style for remaining intro tutorial docs for #36777 (#36817)
1 parent 2038d53 commit 85d1d02

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

doc/source/getting_started/intro_tutorials/01_table_oriented.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ I want to store passenger data of the Titanic. For a number of passengers, I kno
4141

4242
.. ipython:: python
4343
44-
df = pd.DataFrame({
45-
"Name": ["Braund, Mr. Owen Harris",
46-
"Allen, Mr. William Henry",
47-
"Bonnell, Miss. Elizabeth"],
48-
"Age": [22, 35, 58],
49-
"Sex": ["male", "male", "female"]}
44+
df = pd.DataFrame(
45+
{
46+
"Name": [
47+
"Braund, Mr. Owen Harris",
48+
"Allen, Mr. William Henry",
49+
"Bonnell, Miss. Elizabeth",
50+
],
51+
"Age": [22, 35, 58],
52+
"Sex": ["male", "male", "female"],
53+
}
5054
)
5155
df
5256

doc/source/getting_started/intro_tutorials/02_read_write.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ My colleague requested the Titanic data as a spreadsheet.
138138

139139
.. ipython:: python
140140
141-
titanic.to_excel('titanic.xlsx', sheet_name='passengers', index=False)
141+
titanic.to_excel("titanic.xlsx", sheet_name="passengers", index=False)
142142
143143
Whereas ``read_*`` functions are used to read data to pandas, the
144144
``to_*`` methods are used to store data. The :meth:`~DataFrame.to_excel` method stores
@@ -156,7 +156,7 @@ The equivalent read function :meth:`~DataFrame.read_excel` will reload the data
156156

157157
.. ipython:: python
158158
159-
titanic = pd.read_excel('titanic.xlsx', sheet_name='passengers')
159+
titanic = pd.read_excel("titanic.xlsx", sheet_name="passengers")
160160
161161
.. ipython:: python
162162
@@ -166,7 +166,8 @@ The equivalent read function :meth:`~DataFrame.read_excel` will reload the data
166166
:suppress:
167167
168168
import os
169-
os.remove('titanic.xlsx')
169+
170+
os.remove("titanic.xlsx")
170171
171172
.. raw:: html
172173

doc/source/getting_started/intro_tutorials/04_plotting.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ in respectively Paris, Antwerp and London.
4040

4141
.. ipython:: python
4242
43-
air_quality = pd.read_csv("data/air_quality_no2.csv",
44-
index_col=0, parse_dates=True)
43+
air_quality = pd.read_csv("data/air_quality_no2.csv", index_col=0, parse_dates=True)
4544
air_quality.head()
4645
4746
.. note::
@@ -112,9 +111,7 @@ I want to visually compare the :math:`N0_2` values measured in London versus Par
112111
.. ipython:: python
113112
114113
@savefig 04_airqual_scatter.png
115-
air_quality.plot.scatter(x="station_london",
116-
y="station_paris",
117-
alpha=0.5)
114+
air_quality.plot.scatter(x="station_london", y="station_paris", alpha=0.5)
118115
119116
.. raw:: html
120117

@@ -127,8 +124,11 @@ standard Python to get an overview of the available plot methods:
127124

128125
.. ipython:: python
129126
130-
[method_name for method_name in dir(air_quality.plot)
131-
if not method_name.startswith("_")]
127+
[
128+
method_name
129+
for method_name in dir(air_quality.plot)
130+
if not method_name.startswith("_")
131+
]
132132
133133
.. note::
134134
In many development environments as well as ipython and
@@ -196,17 +196,18 @@ I want to further customize, extend or save the resulting plot.
196196

197197
.. ipython:: python
198198
199-
fig, axs = plt.subplots(figsize=(12, 4));
200-
air_quality.plot.area(ax=axs);
199+
fig, axs = plt.subplots(figsize=(12, 4))
200+
air_quality.plot.area(ax=axs)
201201
@savefig 04_airqual_customized.png
202-
axs.set_ylabel("NO$_2$ concentration");
202+
axs.set_ylabel("NO$_2$ concentration")
203203
fig.savefig("no2_concentrations.png")
204204
205205
.. ipython:: python
206206
:suppress:
207207
208208
import os
209-
os.remove('no2_concentrations.png')
209+
210+
os.remove("no2_concentrations.png")
210211
211212
.. raw:: html
212213

doc/source/getting_started/intro_tutorials/05_add_columns.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ in respectively Paris, Antwerp and London.
3939

4040
.. ipython:: python
4141
42-
air_quality = pd.read_csv("data/air_quality_no2.csv",
43-
index_col=0, parse_dates=True)
42+
air_quality = pd.read_csv("data/air_quality_no2.csv", index_col=0, parse_dates=True)
4443
air_quality.head()
4544
4645
.. raw:: html
@@ -95,8 +94,9 @@ I want to check the ratio of the values in Paris versus Antwerp and save the res
9594

9695
.. ipython:: python
9796
98-
air_quality["ratio_paris_antwerp"] = \
97+
air_quality["ratio_paris_antwerp"] = (
9998
air_quality["station_paris"] / air_quality["station_antwerp"]
99+
)
100100
air_quality.head()
101101
102102
The calculation is again element-wise, so the ``/`` is applied *for the
@@ -122,9 +122,12 @@ I want to rename the data columns to the corresponding station identifiers used
122122
.. ipython:: python
123123
124124
air_quality_renamed = air_quality.rename(
125-
columns={"station_antwerp": "BETR801",
126-
"station_paris": "FR04014",
127-
"station_london": "London Westminster"})
125+
columns={
126+
"station_antwerp": "BETR801",
127+
"station_paris": "FR04014",
128+
"station_london": "London Westminster",
129+
}
130+
)
128131
129132
.. ipython:: python
130133

0 commit comments

Comments
 (0)