diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index 1d49dbdee9c03..5e58494f3e1fc 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -3,15 +3,6 @@ .. currentmodule:: pandas -{{ header }} - -.. ipython:: python - :suppress: - - clipdf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': ['p', 'q', 'r']}, - index=['x', 'y', 'z']) - - =============================== IO tools (text, CSV, HDF5, ...) =============================== @@ -137,7 +128,8 @@ usecols : list-like or callable, default ``None`` .. ipython:: python - from io import StringIO, BytesIO + import pandas as pd + from io import StringIO data = ('col1,col2,col3\n' 'a,b,1\n' 'a,b,2\n' @@ -363,6 +355,7 @@ columns: .. ipython:: python + import numpy as np data = ('a,b,c,d\n' '1,2,3,4\n' '5,6,7,8\n' @@ -447,7 +440,6 @@ worth trying. :suppress: import os - os.remove('foo.csv') .. _io.categorical: @@ -757,6 +749,7 @@ result in byte strings being decoded to unicode in the result: .. ipython:: python + from io import BytesIO data = (b'word,length\n' b'Tr\xc3\xa4umen,7\n' b'Gr\xc3\xbc\xc3\x9fe,5') @@ -5562,10 +5555,10 @@ Given the next test set: .. code-block:: python - from numpy.random import randn + import os sz = 1000000 - df = pd.DataFrame({'A': randn(sz), 'B': [1] * sz}) + df = pd.DataFrame({'A': np.random.randn(sz), 'B': [1] * sz}) def test_sql_write(df):