Skip to content

Commit 77dc845

Browse files
committed
Fix double {{ examples
1 parent dacdd0b commit 77dc845

File tree

4 files changed

+23
-54
lines changed

4 files changed

+23
-54
lines changed

pandas/core/base.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,13 @@ def argmax(
714714
Consider dataset containing cereal calories
715715
716716
>>> s = pd.Series(
717-
... {
718-
... {
719-
... "Corn Flakes": 100.0,
720-
... "Almond Delight": 110.0,
721-
... "Cinnamon Toast Crunch": 120.0,
722-
... "Cocoa Puff": 110.0,
723-
... }
724-
... }
717+
... [100.0, 110.0, 120.0, 110.0],
718+
... index=[
719+
... "Corn Flakes",
720+
... "Almond Delight",
721+
... "Cinnamon Toast Crunch",
722+
... "Cocoa Puff",
723+
... ],
725724
... )
726725
>>> s
727726
Corn Flakes 100.0

pandas/core/frame.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -2828,12 +2828,7 @@ def to_stata(
28282828
Examples
28292829
--------
28302830
>>> df = pd.DataFrame(
2831-
... {
2832-
... {
2833-
... "animal": ["falcon", "parrot", "falcon", "parrot"],
2834-
... "speed": [350, 18, 361, 15],
2835-
... }
2836-
... }
2831+
... [["falcon", 350], ["parrot", 18]], columns=["animal", "parrot"]
28372832
... )
28382833
>>> df.to_stata("animals.dta") # doctest: +SKIP
28392834
"""
@@ -3510,13 +3505,8 @@ def to_xml(
35103505
Examples
35113506
--------
35123507
>>> df = pd.DataFrame(
3513-
... {
3514-
... {
3515-
... "shape": ["square", "circle", "triangle"],
3516-
... "degrees": [360, 360, 180],
3517-
... "sides": [4, np.nan, 3],
3518-
... }
3519-
... }
3508+
... [["square", 360, 4], ["circle", 360, np.nan], ["triangle", 180, 3]],
3509+
... columns=["shape", "degrees", "sides"],
35203510
... )
35213511
35223512
>>> df.to_xml() # doctest: +SKIP

pandas/core/generic.py

+11-27
Original file line numberDiff line numberDiff line change
@@ -3933,13 +3933,8 @@ def to_csv(
39333933
Create 'out.csv' containing 'df' without indices
39343934
39353935
>>> df = pd.DataFrame(
3936-
... {
3937-
... {
3938-
... "name": ["Raphael", "Donatello"],
3939-
... "mask": ["red", "purple"],
3940-
... "weapon": ["sai", "bo staff"],
3941-
... }
3942-
... }
3936+
... [["Raphael", "red", "sai"], ["Donatello", "purple", "bo staff"]],
3937+
... columns=["name", "mask", "weapon"],
39433938
... )
39443939
>>> df.to_csv("out.csv", index=False) # doctest: +SKIP
39453940
@@ -5457,13 +5452,10 @@ def reindex(
54575452
Create a dataframe with some fictional data.
54585453
54595454
>>> index = ["Firefox", "Chrome", "Safari", "IE10", "Konqueror"]
5455+
>>> columns = ["http_status", "response_time"]
54605456
>>> df = pd.DataFrame(
5461-
... {
5462-
... {
5463-
... "http_status": [200, 200, 404, 404, 301],
5464-
... "response_time": [0.04, 0.02, 0.07, 0.08, 1.0],
5465-
... }
5466-
... },
5457+
... [[200, 0.04], [200, 0.02], [404, 0.07], [404, 0.08], [301, 1.0]],
5458+
... columns=columns,
54675459
... index=index,
54685460
... )
54695461
>>> df
@@ -9678,13 +9670,8 @@ def resample(
96789670
For DataFrame objects, the keyword `on` can be used to specify the
96799671
column instead of the index for resampling.
96809672
9681-
>>> d = {
9682-
... {
9683-
... "price": [10, 11, 9, 13, 14, 18, 17, 19],
9684-
... "volume": [50, 60, 40, 100, 50, 100, 40, 50],
9685-
... }
9686-
... }
9687-
>>> df = pd.DataFrame(d)
9673+
>>> df = pd.DataFrame([10, 11, 9, 13, 14, 18, 17, 19], columns=["price"])
9674+
>>> df["volume"] = [50, 60, 40, 100, 50, 100, 40, 50]
96889675
>>> df["week_starting"] = pd.date_range("01/01/2018", periods=8, freq="W")
96899676
>>> df
96909677
price volume week_starting
@@ -9706,14 +9693,11 @@ def resample(
97069693
specify on which level the resampling needs to take place.
97079694
97089695
>>> days = pd.date_range("1/1/2000", periods=4, freq="D")
9709-
>>> d2 = {
9710-
... {
9711-
... "price": [10, 11, 9, 13, 14, 18, 17, 19],
9712-
... "volume": [50, 60, 40, 100, 50, 100, 40, 50],
9713-
... }
9714-
... }
97159696
>>> df2 = pd.DataFrame(
9716-
... d2, index=pd.MultiIndex.from_product([days, ["morning", "afternoon"]])
9697+
... [[10, 50],
9698+
... [11, 60], [9, 40], [13, 100], [14, 50], [18, 100], [17, 40], [19, 50]],
9699+
... columns=["price", "volume"]
9700+
... index=pd.MultiIndex.from_product([days, ["morning", "afternoon"]])
97179701
... )
97189702
>>> df2
97199703
price volume

pandas/io/xml.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,7 @@ def read_xml(
916916
Note: if XML document uses default namespace denoted as
917917
`xmlns='<URI>'` without a prefix, you must assign any temporary
918918
namespace prefix such as 'doc' to the URI in order to parse
919-
underlying nodes and/or attributes. For example, ::
920-
921-
namespaces = {{"doc": "https://example.com"}}
919+
underlying nodes and/or attributes.
922920
923921
elems_only : bool, optional, default False
924922
Parse only the child elements at the specified ``xpath``. By default,
@@ -987,9 +985,7 @@ def read_xml(
987985
and unlike ``xpath``, descendants do not need to relate to each other but can
988986
exist any where in document under the repeating element. This memory-
989987
efficient method should be used for very large XML files (500MB, 1GB, or 5GB+).
990-
For example, ::
991-
992-
iterparse = {{"row_element": ["child_elem", "attr", "grandchild_elem"]}}
988+
For example, ``{{"row_element": ["child_elem", "attr", "grandchild_elem"]}}``.
993989
994990
.. versionadded:: 1.5.0
995991

0 commit comments

Comments
 (0)