Skip to content

Commit 301403f

Browse files
TanyaaCJainproost
authored andcommitted
DOC: Make explicit in pandas IO doc the imports and options (pandas-dev#28089)
1 parent 00ba260 commit 301403f

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

doc/source/user_guide/io.rst

+6-13
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33
.. currentmodule:: pandas
44

55

6-
{{ header }}
7-
8-
.. ipython:: python
9-
:suppress:
10-
11-
clipdf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': ['p', 'q', 'r']},
12-
index=['x', 'y', 'z'])
13-
14-
156
===============================
167
IO tools (text, CSV, HDF5, ...)
178
===============================
@@ -137,7 +128,8 @@ usecols : list-like or callable, default ``None``
137128

138129
.. ipython:: python
139130
140-
from io import StringIO, BytesIO
131+
import pandas as pd
132+
from io import StringIO
141133
data = ('col1,col2,col3\n'
142134
'a,b,1\n'
143135
'a,b,2\n'
@@ -360,6 +352,7 @@ columns:
360352

361353
.. ipython:: python
362354
355+
import numpy as np
363356
data = ('a,b,c,d\n'
364357
'1,2,3,4\n'
365358
'5,6,7,8\n'
@@ -440,7 +433,6 @@ worth trying.
440433
:suppress:
441434
442435
import os
443-
444436
os.remove('foo.csv')
445437
446438
.. _io.categorical:
@@ -748,6 +740,7 @@ result in byte strings being decoded to unicode in the result:
748740

749741
.. ipython:: python
750742
743+
from io import BytesIO
751744
data = (b'word,length\n'
752745
b'Tr\xc3\xa4umen,7\n'
753746
b'Gr\xc3\xbc\xc3\x9fe,5')
@@ -5604,10 +5597,10 @@ Given the next test set:
56045597

56055598
.. code-block:: python
56065599
5607-
from numpy.random import randn
5600+
import os
56085601
56095602
sz = 1000000
5610-
df = pd.DataFrame({'A': randn(sz), 'B': [1] * sz})
5603+
df = pd.DataFrame({'A': np.random.randn(sz), 'B': [1] * sz})
56115604
56125605
56135606
def test_sql_write(df):

0 commit comments

Comments
 (0)