13
13
randn = np.random.randn
14
14
randint = np.random.randint
15
15
np.set_printoptions(precision = 4 , suppress = True )
16
- from pandas.compat import lrange, lzip
16
+ from pandas.compat import range , zip
17
17
18
18
***************************
19
19
Indexing and Selecting Data
@@ -294,7 +294,7 @@ The ``.iloc`` attribute is the primary access method. The following are valid in
294
294
295
295
.. ipython :: python
296
296
297
- s1 = Series(np.random.randn(5 ),index = lrange( 0 ,10 ,2 ))
297
+ s1 = Series(np.random.randn(5 ),index = list ( range ( 0 ,10 ,2 ) ))
298
298
s1
299
299
s1.iloc[:3 ]
300
300
s1.iloc[3 ]
@@ -311,8 +311,8 @@ With a DataFrame
311
311
.. ipython :: python
312
312
313
313
df1 = DataFrame(np.random.randn(6 ,4 ),
314
- index = lrange( 0 ,12 ,2 ),
315
- columns = lrange( 0 ,8 ,2 ))
314
+ index = list ( range ( 0 ,12 ,2 ) ),
315
+ columns = list ( range ( 0 ,8 ,2 ) ))
316
316
df1
317
317
318
318
Select via integer slicing
@@ -787,7 +787,7 @@ numpy array. For instance,
787
787
.. ipython :: python
788
788
789
789
dflookup = DataFrame(np.random.rand(20 ,4 ), columns = [' A' ,' B' ,' C' ,' D' ])
790
- dflookup.lookup(lrange( 0 ,10 ,2 ), [' B' ,' C' ,' A' ,' B' ,' D' ])
790
+ dflookup.lookup(list ( range ( 0 ,10 ,2 ) ), [' B' ,' C' ,' A' ,' B' ,' D' ])
791
791
792
792
Setting values in mixed-type DataFrame
793
793
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -897,7 +897,7 @@ display:
897
897
898
898
.. ipython :: python
899
899
900
- index = Index(lrange( 5 ), name = ' rows' )
900
+ index = Index(list ( range ( 5 ) ), name = ' rows' )
901
901
columns = Index([' A' , ' B' , ' C' ], name = ' cols' )
902
902
df = DataFrame(np.random.randn(5 , 3 ), index = index, columns = columns)
903
903
df
@@ -972,7 +972,7 @@ can think of ``MultiIndex`` an array of tuples where each tuple is unique. A
972
972
973
973
arrays = [[' bar' , ' bar' , ' baz' , ' baz' , ' foo' , ' foo' , ' qux' , ' qux' ],
974
974
[' one' , ' two' , ' one' , ' two' , ' one' , ' two' , ' one' , ' two' ]]
975
- tuples = lzip( * arrays)
975
+ tuples = list ( zip ( * arrays) )
976
976
tuples
977
977
index = MultiIndex.from_tuples(tuples, names = [' first' , ' second' ])
978
978
s = Series(randn(8 ), index = index)
0 commit comments