Skip to content

Commit

Permalink
made code segments as ipython blocks
Browse files Browse the repository at this point in the history
changed python code segments from
code-block:: none to ipython:: python
  • Loading branch information
natethedrummer committed May 25, 2017
1 parent be34885 commit ff53ca9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/source/comparison_with_sas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ Python determines the length of a character string with the ``len`` function.
``len`` includes trailing blanks. Use ``len`` and ``rstrip`` to exclude
trailing blanks.

.. code-block:: none
.. ipython:: python
tips['time'].str.len()
tips['time'].str.rstrip().str.len()
Expand All @@ -407,7 +407,7 @@ substring. If the substring is found, the function returns its
position. Keep in mind that Python indexes are zero-based and
the function will return -1 if it fails to find the substring.

.. code-block:: none
.. ipython:: python
tips['sex'].str.find("ALE")
Expand All @@ -429,7 +429,7 @@ In Python, you can use ``[]`` notation to extract a substring
from a string by position locations. Keep in mind that Python
indexes are zero-based.

.. code-block:: none
.. ipython:: python
tips['sex'].str[0:1]
Expand Down Expand Up @@ -457,7 +457,7 @@ Python extracts a substring from a string based on its text
by using regular expressions. There are much more powerful
approaches, but this just shows a simple approach.

.. code-block:: none
.. ipython:: python
firstlast = pd.DataFrame({'String': ['John Smith', 'Jane Cook']})
firstlast['First_Name'] = firstlast['String'].str.split(" ", expand=True)[0]
Expand Down Expand Up @@ -485,7 +485,7 @@ the case of the argument.
The equivalent Python functions are ``upper``, ``lower``, and ``title``.

.. code-block:: none
.. ipython:: python
firstlast = pd.DataFrame({'String': ['John Smith', 'Jane Cook']})
firstlast['string_up'] = firstlast['String'].str.upper()
Expand Down

0 comments on commit ff53ca9

Please sign in to comment.