Skip to content

Commit 18a9b7c

Browse files
committed
DOC: Update io.rst to explicitly add imports and options
- imported pandas and added its options in the first visible code block - moved the suppressed or invisible code block using clipdf just before the code block using the clipdf variable - imported `BytesIO` in its first occurrence of requirement unlike previously imported along with `StringIO` - imported os again for adding it on its first occurrence of requirement in a visible code block and is earlier imported in a suppressed code block.
1 parent 035e35b commit 18a9b7c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

doc/source/user_guide/io.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
.. currentmodule:: pandas
44

5-
.. ipython:: python
6-
:suppress:
7-
8-
import pandas as pd
9-
pd.options.display.max_rows = 15
10-
clipdf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': ['p', 'q', 'r']},
11-
index=['x', 'y', 'z'])
12-
135

146
===============================
157
IO tools (text, CSV, HDF5, ...)
@@ -136,7 +128,9 @@ usecols : list-like or callable, default ``None``
136128

137129
.. ipython:: python
138130
139-
from io import StringIO, BytesIO
131+
import pandas as pd
132+
pd.options.display.max_rows = 15
133+
from io import StringIO
140134
data = ('col1,col2,col3\n'
141135
'a,b,1\n'
142136
'a,b,2\n'
@@ -757,6 +751,7 @@ result in byte strings being decoded to unicode in the result:
757751

758752
.. ipython:: python
759753
754+
from io import BytesIO
760755
data = (b'word,length\n'
761756
b'Tr\xc3\xa4umen,7\n'
762757
b'Gr\xc3\xbc\xc3\x9fe,5')
@@ -3267,6 +3262,12 @@ clipboard (CTRL-C on many operating systems):
32673262
32683263
And then import the data directly to a ``DataFrame`` by calling:
32693264

3265+
.. ipython:: python
3266+
:suppress:
3267+
3268+
clipdf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': ['p', 'q', 'r']},
3269+
index=['x', 'y', 'z'])
3270+
32703271
.. code-block:: python
32713272
32723273
>>> clipdf = pd.read_clipboard()
@@ -5563,6 +5564,8 @@ Given the next test set:
55635564

55645565
.. code-block:: python
55655566
5567+
import os
5568+
55665569
sz = 1000000
55675570
df = pd.DataFrame({'A': np.random.randn(sz), 'B': [1] * sz})
55685571

0 commit comments

Comments
 (0)