diff --git a/sdks/python/apache_beam/dataframe/frame_base.py b/sdks/python/apache_beam/dataframe/frame_base.py index 90f34d45dd98..3b9755232e80 100644 --- a/sdks/python/apache_beam/dataframe/frame_base.py +++ b/sdks/python/apache_beam/dataframe/frame_base.py @@ -606,6 +606,21 @@ def wrap(func): " :skipif: True"), re.sub(r"^", " ", content, flags=re.MULTILINE), ]) + elif "Examples" in content and ">>>" in content: + # some new examples don't have the correct heading + # this catches those examples + split_content = content.split("Examples") + content = '\n\n'.join([ + split_content[0], + "Examples\n", + # Indent the code snippet under a doctest heading, + # add skipif option. This makes sure our doctest + # framework doesn't run these pandas tests. + (".. doctest::\n" + " :skipif: True"), + re.sub(r"^", " ", content, flags=re.MULTILINE), + split_content[1] + ]) else: content = content.replace('DataFrame', 'DeferredDataFrame').replace( 'Series', 'DeferredSeries')