Skip to content

Commit

Permalink
Fix double {{ examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Jan 13, 2024
1 parent dacdd0b commit 77dc845
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 54 deletions.
15 changes: 7 additions & 8 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,14 +714,13 @@ def argmax(
Consider dataset containing cereal calories
>>> s = pd.Series(
... {
... {
... "Corn Flakes": 100.0,
... "Almond Delight": 110.0,
... "Cinnamon Toast Crunch": 120.0,
... "Cocoa Puff": 110.0,
... }
... }
... [100.0, 110.0, 120.0, 110.0],
... index=[
... "Corn Flakes",
... "Almond Delight",
... "Cinnamon Toast Crunch",
... "Cocoa Puff",
... ],
... )
>>> s
Corn Flakes 100.0
Expand Down
16 changes: 3 additions & 13 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2828,12 +2828,7 @@ def to_stata(
Examples
--------
>>> df = pd.DataFrame(
... {
... {
... "animal": ["falcon", "parrot", "falcon", "parrot"],
... "speed": [350, 18, 361, 15],
... }
... }
... [["falcon", 350], ["parrot", 18]], columns=["animal", "parrot"]
... )
>>> df.to_stata("animals.dta") # doctest: +SKIP
"""
Expand Down Expand Up @@ -3510,13 +3505,8 @@ def to_xml(
Examples
--------
>>> df = pd.DataFrame(
... {
... {
... "shape": ["square", "circle", "triangle"],
... "degrees": [360, 360, 180],
... "sides": [4, np.nan, 3],
... }
... }
... [["square", 360, 4], ["circle", 360, np.nan], ["triangle", 180, 3]],
... columns=["shape", "degrees", "sides"],
... )
>>> df.to_xml() # doctest: +SKIP
Expand Down
38 changes: 11 additions & 27 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3933,13 +3933,8 @@ def to_csv(
Create 'out.csv' containing 'df' without indices
>>> df = pd.DataFrame(
... {
... {
... "name": ["Raphael", "Donatello"],
... "mask": ["red", "purple"],
... "weapon": ["sai", "bo staff"],
... }
... }
... [["Raphael", "red", "sai"], ["Donatello", "purple", "bo staff"]],
... columns=["name", "mask", "weapon"],
... )
>>> df.to_csv("out.csv", index=False) # doctest: +SKIP
Expand Down Expand Up @@ -5457,13 +5452,10 @@ def reindex(
Create a dataframe with some fictional data.
>>> index = ["Firefox", "Chrome", "Safari", "IE10", "Konqueror"]
>>> columns = ["http_status", "response_time"]
>>> df = pd.DataFrame(
... {
... {
... "http_status": [200, 200, 404, 404, 301],
... "response_time": [0.04, 0.02, 0.07, 0.08, 1.0],
... }
... },
... [[200, 0.04], [200, 0.02], [404, 0.07], [404, 0.08], [301, 1.0]],
... columns=columns,
... index=index,
... )
>>> df
Expand Down Expand Up @@ -9678,13 +9670,8 @@ def resample(
For DataFrame objects, the keyword `on` can be used to specify the
column instead of the index for resampling.
>>> d = {
... {
... "price": [10, 11, 9, 13, 14, 18, 17, 19],
... "volume": [50, 60, 40, 100, 50, 100, 40, 50],
... }
... }
>>> df = pd.DataFrame(d)
>>> df = pd.DataFrame([10, 11, 9, 13, 14, 18, 17, 19], columns=["price"])
>>> df["volume"] = [50, 60, 40, 100, 50, 100, 40, 50]
>>> df["week_starting"] = pd.date_range("01/01/2018", periods=8, freq="W")
>>> df
price volume week_starting
Expand All @@ -9706,14 +9693,11 @@ def resample(
specify on which level the resampling needs to take place.
>>> days = pd.date_range("1/1/2000", periods=4, freq="D")
>>> d2 = {
... {
... "price": [10, 11, 9, 13, 14, 18, 17, 19],
... "volume": [50, 60, 40, 100, 50, 100, 40, 50],
... }
... }
>>> df2 = pd.DataFrame(
... d2, index=pd.MultiIndex.from_product([days, ["morning", "afternoon"]])
... [[10, 50],
... [11, 60], [9, 40], [13, 100], [14, 50], [18, 100], [17, 40], [19, 50]],
... columns=["price", "volume"]
... index=pd.MultiIndex.from_product([days, ["morning", "afternoon"]])
... )
>>> df2
price volume
Expand Down
8 changes: 2 additions & 6 deletions pandas/io/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,9 +916,7 @@ def read_xml(
Note: if XML document uses default namespace denoted as
`xmlns='<URI>'` without a prefix, you must assign any temporary
namespace prefix such as 'doc' to the URI in order to parse
underlying nodes and/or attributes. For example, ::
namespaces = {{"doc": "https://example.com"}}
underlying nodes and/or attributes.
elems_only : bool, optional, default False
Parse only the child elements at the specified ``xpath``. By default,
Expand Down Expand Up @@ -987,9 +985,7 @@ def read_xml(
and unlike ``xpath``, descendants do not need to relate to each other but can
exist any where in document under the repeating element. This memory-
efficient method should be used for very large XML files (500MB, 1GB, or 5GB+).
For example, ::
iterparse = {{"row_element": ["child_elem", "attr", "grandchild_elem"]}}
For example, ``{{"row_element": ["child_elem", "attr", "grandchild_elem"]}}``.
.. versionadded:: 1.5.0
Expand Down

0 comments on commit 77dc845

Please sign in to comment.