File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 5
5
:suppress:
6
6
7
7
import numpy as np
8
- np.random.seed(123456 )
9
8
import pandas as pd
10
- import pandas.util.testing as tm
9
+
10
+ np.random.seed(123456 )
11
11
np.set_printoptions(precision = 4 , suppress = True )
12
12
pd.options.display.max_rows = 15
13
13
@@ -26,7 +26,7 @@ data structures have a ``to_sparse`` method:
26
26
27
27
.. ipython :: python
28
28
29
- ts = pd.Series(randn(10 ))
29
+ ts = pd.Series(np.random. randn(10 ))
30
30
ts[2 :- 2 ] = np.nan
31
31
sts = ts.to_sparse()
32
32
sts
@@ -44,7 +44,7 @@ large, mostly NA ``DataFrame``:
44
44
45
45
.. ipython :: python
46
46
47
- df = pd.DataFrame(randn(10000 , 4 ))
47
+ df = pd.DataFrame(np.random. randn(10000 , 4 ))
48
48
df.iloc[:9998 ] = np.nan
49
49
sdf = df.to_sparse()
50
50
sdf
@@ -94,7 +94,8 @@ distinct from the ``fill_value``:
94
94
.. ipython :: python
95
95
96
96
arr = np.random.randn(10 )
97
- arr[2 :5 ] = np.nan; arr[7 :8 ] = np.nan
97
+ arr[2 :5 ] = np.nan
98
+ arr[7 :8 ] = np.nan
98
99
sparr = pd.SparseArray(arr)
99
100
sparr
100
101
@@ -244,7 +245,7 @@ The method requires a ``MultiIndex`` with two or more levels.
244
245
(1 , 1 , ' b' , 1 ),
245
246
(2 , 1 , ' b' , 0 ),
246
247
(2 , 1 , ' b' , 1 )],
247
- names = [' A' , ' B' , ' C' , ' D' ])
248
+ names = [' A' , ' B' , ' C' , ' D' ])
248
249
249
250
s
250
251
# SparseSeries
You can’t perform that action at this time.
0 commit comments