5
5
import numpy as np
6
6
import pytest
7
7
8
- from pandas .compat import lmap
9
8
from pandas .errors import ParserError
10
9
11
10
import pandas as pd
@@ -120,8 +119,8 @@ def test_to_csv_from_csv3(self):
120
119
df2 .to_csv (path , mode = 'a' , header = False )
121
120
xp = pd .concat ([df1 , df2 ])
122
121
rs = pd .read_csv (path , index_col = 0 )
123
- rs .columns = lmap ( int , rs .columns )
124
- xp .columns = lmap ( int , xp .columns )
122
+ rs .columns = [ int ( label ) for label in rs .columns ]
123
+ xp .columns = [ int ( label ) for label in xp .columns ]
125
124
assert_frame_equal (xp , rs )
126
125
127
126
def test_to_csv_from_csv4 (self ):
@@ -292,19 +291,24 @@ def _to_uni(x):
292
291
if r_dtype :
293
292
if r_dtype == 'u' : # unicode
294
293
r_dtype = 'O'
295
- recons .index = np .array (lmap (_to_uni , recons .index ),
296
- dtype = r_dtype )
297
- df .index = np .array (lmap (_to_uni , df .index ), dtype = r_dtype )
294
+ recons .index = np .array (
295
+ [_to_uni (label ) for label in recons .index ],
296
+ dtype = r_dtype )
297
+ df .index = np .array (
298
+ [_to_uni (label ) for label in df .index ], dtype = r_dtype )
298
299
elif r_dtype == 'dt' : # unicode
299
300
r_dtype = 'O'
300
- recons .index = np .array (lmap (Timestamp , recons .index ),
301
- dtype = r_dtype )
301
+ recons .index = np .array (
302
+ [Timestamp (label ) for label in recons .index ],
303
+ dtype = r_dtype )
302
304
df .index = np .array (
303
- lmap (Timestamp , df .index ), dtype = r_dtype )
305
+ [Timestamp (label ) for label in df .index ],
306
+ dtype = r_dtype )
304
307
elif r_dtype == 'p' :
305
308
r_dtype = 'O'
309
+ idx_list = to_datetime (recons .index )
306
310
recons .index = np .array (
307
- list ( map ( Timestamp , to_datetime ( recons . index ))) ,
311
+ [ Timestamp ( label ) for label in idx_list ] ,
308
312
dtype = r_dtype )
309
313
df .index = np .array (
310
314
list (map (Timestamp , df .index .to_timestamp ())),
@@ -316,23 +320,29 @@ def _to_uni(x):
316
320
if c_dtype :
317
321
if c_dtype == 'u' :
318
322
c_dtype = 'O'
319
- recons .columns = np .array (lmap (_to_uni , recons .columns ),
320
- dtype = c_dtype )
323
+ recons .columns = np .array (
324
+ [_to_uni (label ) for label in recons .columns ],
325
+ dtype = c_dtype )
321
326
df .columns = np .array (
322
- lmap (_to_uni , df .columns ), dtype = c_dtype )
327
+ [_to_uni (label ) for label in df .columns ],
328
+ dtype = c_dtype )
323
329
elif c_dtype == 'dt' :
324
330
c_dtype = 'O'
325
- recons .columns = np .array (lmap (Timestamp , recons .columns ),
326
- dtype = c_dtype )
331
+ recons .columns = np .array (
332
+ [Timestamp (label ) for label in recons .columns ],
333
+ dtype = c_dtype )
327
334
df .columns = np .array (
328
- lmap (Timestamp , df .columns ), dtype = c_dtype )
335
+ [Timestamp (label ) for label in df .columns ],
336
+ dtype = c_dtype )
329
337
elif c_dtype == 'p' :
330
338
c_dtype = 'O'
339
+ col_list = to_datetime (recons .columns )
331
340
recons .columns = np .array (
332
- lmap ( Timestamp , to_datetime ( recons . columns )) ,
341
+ [ Timestamp ( label ) for label in col_list ] ,
333
342
dtype = c_dtype )
343
+ col_list = df .columns .to_timestamp ()
334
344
df .columns = np .array (
335
- lmap ( Timestamp , df . columns . to_timestamp ()) ,
345
+ [ Timestamp ( label ) for label in col_list ] ,
336
346
dtype = c_dtype )
337
347
else :
338
348
c_dtype = type_map .get (c_dtype )
0 commit comments