Skip to content

Commit ad71600

Browse files
committed
doc eg fmt
1 parent bc013c0 commit ad71600

File tree

1 file changed

+87
-69
lines changed

1 file changed

+87
-69
lines changed

python/pyspark/sql/plot/core.py

+87-69
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@ def line(self, x: str, y: Union[str, list[str]], **kwargs: Any) -> "Figure":
149149
150150
Examples
151151
--------
152-
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
153-
>>> columns = ["category", "int_val", "float_val"]
154-
>>> df = spark.createDataFrame(data, columns)
155-
>>> df.plot.line(x="category", y="int_val") # doctest: +SKIP
156-
>>> df.plot.line(x="category", y=["int_val", "float_val"]) # doctest: +SKIP
152+
.. plotly::
153+
154+
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
155+
>>> columns = ["category", "int_val", "float_val"]
156+
>>> df = spark.createDataFrame(data, columns)
157+
>>> df.plot.line(x="category", y="int_val") # doctest: +SKIP
158+
>>> df.plot.line(x="category", y=["int_val", "float_val"]) # doctest: +SKIP
157159
"""
158160
return self(kind="line", x=x, y=y, **kwargs)
159161

@@ -182,11 +184,13 @@ def bar(self, x: str, y: Union[str, list[str]], **kwargs: Any) -> "Figure":
182184
183185
Examples
184186
--------
185-
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
186-
>>> columns = ["category", "int_val", "float_val"]
187-
>>> df = spark.createDataFrame(data, columns)
188-
>>> df.plot.bar(x="category", y="int_val") # doctest: +SKIP
189-
>>> df.plot.bar(x="category", y=["int_val", "float_val"]) # doctest: +SKIP
187+
.. plotly::
188+
189+
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
190+
>>> columns = ["category", "int_val", "float_val"]
191+
>>> df = spark.createDataFrame(data, columns)
192+
>>> df.plot.bar(x="category", y="int_val") # doctest: +SKIP
193+
>>> df.plot.bar(x="category", y=["int_val", "float_val"]) # doctest: +SKIP
190194
"""
191195
return self(kind="bar", x=x, y=y, **kwargs)
192196

@@ -224,13 +228,15 @@ def barh(self, x: str, y: Union[str, list[str]], **kwargs: Any) -> "Figure":
224228
225229
Examples
226230
--------
227-
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
228-
>>> columns = ["category", "int_val", "float_val"]
229-
>>> df = spark.createDataFrame(data, columns)
230-
>>> df.plot.barh(x="int_val", y="category") # doctest: +SKIP
231-
>>> df.plot.barh(
232-
... x=["int_val", "float_val"], y="category"
233-
... ) # doctest: +SKIP
231+
.. plotly::
232+
233+
>>> data = [("A", 10, 1.5), ("B", 30, 2.5), ("C", 20, 3.5)]
234+
>>> columns = ["category", "int_val", "float_val"]
235+
>>> df = spark.createDataFrame(data, columns)
236+
>>> df.plot.barh(x="int_val", y="category") # doctest: +SKIP
237+
>>> df.plot.barh(
238+
... x=["int_val", "float_val"], y="category"
239+
... ) # doctest: +SKIP
234240
"""
235241
return self(kind="barh", x=x, y=y, **kwargs)
236242

@@ -260,10 +266,12 @@ def scatter(self, x: str, y: str, **kwargs: Any) -> "Figure":
260266
261267
Examples
262268
--------
263-
>>> data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
264-
>>> columns = ['length', 'width', 'species']
265-
>>> df = spark.createDataFrame(data, columns)
266-
>>> df.plot.scatter(x='length', y='width') # doctest: +SKIP
269+
.. plotly::
270+
271+
>>> data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
272+
>>> columns = ['length', 'width', 'species']
273+
>>> df = spark.createDataFrame(data, columns)
274+
>>> df.plot.scatter(x='length', y='width') # doctest: +SKIP
267275
"""
268276
return self(kind="scatter", x=x, y=y, **kwargs)
269277

@@ -288,16 +296,18 @@ def area(self, x: str, y: Union[str, list[str]], **kwargs: Any) -> "Figure":
288296
289297
Examples
290298
--------
291-
>>> from datetime import datetime
292-
>>> data = [
293-
... (3, 5, 20, datetime(2018, 1, 31)),
294-
... (2, 5, 42, datetime(2018, 2, 28)),
295-
... (3, 6, 28, datetime(2018, 3, 31)),
296-
... (9, 12, 62, datetime(2018, 4, 30))
297-
... ]
298-
>>> columns = ["sales", "#s", "visits", "date"]
299-
>>> df = spark.createDataFrame(data, columns)
300-
>>> df.plot.area(x='date', y=['sales', '#s', 'visits']) # doctest: +SKIP
299+
.. plotly::
300+
301+
>>> from datetime import datetime
302+
>>> data = [
303+
... (3, 5, 20, datetime(2018, 1, 31)),
304+
... (2, 5, 42, datetime(2018, 2, 28)),
305+
... (3, 6, 28, datetime(2018, 3, 31)),
306+
... (9, 12, 62, datetime(2018, 4, 30))
307+
... ]
308+
>>> columns = ["sales", "#s", "visits", "date"]
309+
>>> df = spark.createDataFrame(data, columns)
310+
>>> df.plot.area(x='date', y=['sales', '#s', 'visits']) # doctest: +SKIP
301311
"""
302312
return self(kind="area", x=x, y=y, **kwargs)
303313

@@ -323,17 +333,19 @@ def pie(self, x: str, y: Optional[str], **kwargs: Any) -> "Figure":
323333
324334
Examples
325335
--------
326-
>>> from datetime import datetime
327-
>>> data = [
328-
... (3, 5, 20, datetime(2018, 1, 31)),
329-
... (2, 5, 42, datetime(2018, 2, 28)),
330-
... (3, 6, 28, datetime(2018, 3, 31)),
331-
... (9, 12, 62, datetime(2018, 4, 30))
332-
... ]
333-
>>> columns = ["sales", "#s", "visits", "date"]
334-
>>> df = spark.createDataFrame(data, columns)
335-
>>> df.plot.pie(x='date', y='sales') # doctest: +SKIP
336-
>>> df.plot.pie(x='date', subplots=True) # doctest: +SKIP
336+
.. plotly::
337+
338+
>>> from datetime import datetime
339+
>>> data = [
340+
... (3, 5, 20, datetime(2018, 1, 31)),
341+
... (2, 5, 42, datetime(2018, 2, 28)),
342+
... (3, 6, 28, datetime(2018, 3, 31)),
343+
... (9, 12, 62, datetime(2018, 4, 30))
344+
... ]
345+
>>> columns = ["sales", "#s", "visits", "date"]
346+
>>> df = spark.createDataFrame(data, columns)
347+
>>> df.plot.pie(x='date', y='sales') # doctest: +SKIP
348+
>>> df.plot.pie(x='date', subplots=True) # doctest: +SKIP
337349
"""
338350
return self(kind="pie", x=x, y=y, **kwargs)
339351

@@ -365,21 +377,23 @@ def box(self, column: Optional[Union[str, List[str]]] = None, **kwargs: Any) ->
365377
366378
Examples
367379
--------
368-
>>> data = [
369-
... ("A", 50, 55),
370-
... ("B", 55, 60),
371-
... ("C", 60, 65),
372-
... ("D", 65, 70),
373-
... ("E", 70, 75),
374-
... ("F", 10, 15),
375-
... ("G", 85, 90),
376-
... ("H", 5, 150),
377-
... ]
378-
>>> columns = ["student", "math_score", "english_score"]
379-
>>> df = spark.createDataFrame(data, columns)
380-
>>> df.plot.box() # doctest: +SKIP
381-
>>> df.plot.box(column="math_score") # doctest: +SKIP
382-
>>> df.plot.box(column=["math_score", "english_score"]) # doctest: +SKIP
380+
.. plotly::
381+
382+
>>> data = [
383+
... ("A", 50, 55),
384+
... ("B", 55, 60),
385+
... ("C", 60, 65),
386+
... ("D", 65, 70),
387+
... ("E", 70, 75),
388+
... ("F", 10, 15),
389+
... ("G", 85, 90),
390+
... ("H", 5, 150),
391+
... ]
392+
>>> columns = ["student", "math_score", "english_score"]
393+
>>> df = spark.createDataFrame(data, columns)
394+
>>> df.plot.box() # doctest: +SKIP
395+
>>> df.plot.box(column="math_score") # doctest: +SKIP
396+
>>> df.plot.box(column=["math_score", "english_score"]) # doctest: +SKIP
383397
"""
384398
return self(kind="box", column=column, **kwargs)
385399

@@ -419,12 +433,14 @@ def kde(
419433
420434
Examples
421435
--------
422-
>>> data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
423-
>>> columns = ["length", "width", "species"]
424-
>>> df = spark.createDataFrame(data, columns)
425-
>>> df.plot.kde(bw_method=0.3, ind=100) # doctest: +SKIP
426-
>>> df.plot.kde(column=["length", "width"], bw_method=0.3, ind=100) # doctest: +SKIP
427-
>>> df.plot.kde(column="length", bw_method=0.3, ind=100) # doctest: +SKIP
436+
.. plotly::
437+
438+
>>> data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
439+
>>> columns = ["length", "width", "species"]
440+
>>> df = spark.createDataFrame(data, columns)
441+
>>> df.plot.kde(bw_method=0.3, ind=100) # doctest: +SKIP
442+
>>> df.plot.kde(column=["length", "width"], bw_method=0.3, ind=100) # doctest: +SKIP
443+
>>> df.plot.kde(column="length", bw_method=0.3, ind=100) # doctest: +SKIP
428444
"""
429445
return self(kind="kde", column=column, bw_method=bw_method, ind=ind, **kwargs)
430446

@@ -454,12 +470,14 @@ def hist(
454470
455471
Examples
456472
--------
457-
>>> data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
458-
>>> columns = ["length", "width", "species"]
459-
>>> df = spark.createDataFrame(data, columns)
460-
>>> df.plot.hist(bins=4) # doctest: +SKIP
461-
>>> df.plot.hist(column=["length", "width"]) # doctest: +SKIP
462-
>>> df.plot.hist(column="length", bins=4) # doctest: +SKIP
473+
.. plotly::
474+
475+
>>> data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
476+
>>> columns = ["length", "width", "species"]
477+
>>> df = spark.createDataFrame(data, columns)
478+
>>> df.plot.hist(bins=4) # doctest: +SKIP
479+
>>> df.plot.hist(column=["length", "width"]) # doctest: +SKIP
480+
>>> df.plot.hist(column="length", bins=4) # doctest: +SKIP
463481
"""
464482
return self(kind="hist", column=column, bins=bins, **kwargs)
465483

0 commit comments

Comments
 (0)