108
108
example of a valid callable argument would be ``lambda x: x.upper() in
109
109
['AAA', 'BBB', 'DDD']``. Using this parameter results in much faster
110
110
parsing time and lower memory usage.
111
- as_recarray : boolean, default False
112
- .. deprecated:: 0.19.0
113
- Please call `pd.read_csv(...).to_records()` instead.
114
-
115
- Return a NumPy recarray instead of a DataFrame after parsing the data.
116
- If set to True, this option takes precedence over the `squeeze` parameter.
117
- In addition, as row indices are not available in such a format, the
118
- `index_col` parameter will be ignored.
119
111
squeeze : boolean, default False
120
112
If the parsed data only contains one column then return a Series
121
113
prefix : str, default None
@@ -506,7 +498,6 @@ def _read(filepath_or_buffer, kwds):
506
498
507
499
_c_parser_defaults = {
508
500
'delim_whitespace' : False ,
509
- 'as_recarray' : False ,
510
501
'na_filter' : True ,
511
502
'compact_ints' : False ,
512
503
'use_unsigned' : False ,
@@ -532,14 +523,12 @@ def _read(filepath_or_buffer, kwds):
532
523
}
533
524
534
525
_deprecated_defaults = {
535
- 'as_recarray' : None ,
536
526
'buffer_lines' : None ,
537
527
'compact_ints' : None ,
538
528
'use_unsigned' : None ,
539
529
'tupleize_cols' : None
540
530
}
541
531
_deprecated_args = {
542
- 'as_recarray' ,
543
532
'buffer_lines' ,
544
533
'compact_ints' ,
545
534
'use_unsigned' ,
@@ -614,7 +603,6 @@ def parser_f(filepath_or_buffer,
614
603
# Internal
615
604
doublequote = True ,
616
605
delim_whitespace = False ,
617
- as_recarray = None ,
618
606
compact_ints = None ,
619
607
use_unsigned = None ,
620
608
low_memory = _c_parser_defaults ['low_memory' ],
@@ -685,7 +673,6 @@ def parser_f(filepath_or_buffer,
685
673
compact_ints = compact_ints ,
686
674
use_unsigned = use_unsigned ,
687
675
delim_whitespace = delim_whitespace ,
688
- as_recarray = as_recarray ,
689
676
warn_bad_lines = warn_bad_lines ,
690
677
error_bad_lines = error_bad_lines ,
691
678
low_memory = low_memory ,
@@ -971,9 +958,7 @@ def _clean_options(self, options, engine):
971
958
"and will be removed in a future version."
972
959
.format (arg = arg ))
973
960
974
- if arg == 'as_recarray' :
975
- msg += ' Please call pd.to_csv(...).to_records() instead.'
976
- elif arg == 'tupleize_cols' :
961
+ if arg == 'tupleize_cols' :
977
962
msg += (' Column tuples will then '
978
963
'always be converted to MultiIndex.' )
979
964
@@ -1059,9 +1044,6 @@ def read(self, nrows=None):
1059
1044
1060
1045
ret = self ._engine .read (nrows )
1061
1046
1062
- if self .options .get ('as_recarray' ):
1063
- return ret
1064
-
1065
1047
# May alter columns / col_dict
1066
1048
index , columns , col_dict = self ._create_index (ret )
1067
1049
@@ -1279,7 +1261,6 @@ def __init__(self, kwds):
1279
1261
1280
1262
self .true_values = kwds .get ('true_values' )
1281
1263
self .false_values = kwds .get ('false_values' )
1282
- self .as_recarray = kwds .get ('as_recarray' , False )
1283
1264
self .tupleize_cols = kwds .get ('tupleize_cols' , False )
1284
1265
self .mangle_dupe_cols = kwds .get ('mangle_dupe_cols' , True )
1285
1266
self .infer_datetime_format = kwds .pop ('infer_datetime_format' , False )
@@ -1295,9 +1276,6 @@ def __init__(self, kwds):
1295
1276
if isinstance (self .header , (list , tuple , np .ndarray )):
1296
1277
if not all (map (is_integer , self .header )):
1297
1278
raise ValueError ("header must be integer or list of integers" )
1298
- if kwds .get ('as_recarray' ):
1299
- raise ValueError ("cannot specify as_recarray when "
1300
- "specifying a multi-index header" )
1301
1279
if kwds .get ('usecols' ):
1302
1280
raise ValueError ("cannot specify usecols when "
1303
1281
"specifying a multi-index header" )
@@ -1900,10 +1878,6 @@ def read(self, nrows=None):
1900
1878
# Done with first read, next time raise StopIteration
1901
1879
self ._first_chunk = False
1902
1880
1903
- if self .as_recarray :
1904
- # what to do if there are leading columns?
1905
- return data
1906
-
1907
1881
names = self .names
1908
1882
1909
1883
if self ._reader .leading_cols :
@@ -2306,9 +2280,6 @@ def read(self, rows=None):
2306
2280
columns , data = self ._do_date_conversions (columns , data )
2307
2281
2308
2282
data = self ._convert_data (data )
2309
- if self .as_recarray :
2310
- return self ._to_recarray (data , columns )
2311
-
2312
2283
index , columns = self ._make_index (data , alldata , columns , indexnamerow )
2313
2284
2314
2285
return index , columns , data
@@ -2376,19 +2347,6 @@ def _clean_mapping(mapping):
2376
2347
clean_na_fvalues , self .verbose ,
2377
2348
clean_conv , clean_dtypes )
2378
2349
2379
- def _to_recarray (self , data , columns ):
2380
- dtypes = []
2381
- o = compat .OrderedDict ()
2382
-
2383
- # use the columns to "order" the keys
2384
- # in the unordered 'data' dictionary
2385
- for col in columns :
2386
- dtypes .append ((str (col ), data [col ].dtype ))
2387
- o [col ] = data [col ]
2388
-
2389
- tuples = lzip (* o .values ())
2390
- return np .array (tuples , dtypes )
2391
-
2392
2350
def _infer_columns (self ):
2393
2351
names = self .names
2394
2352
num_original_columns = 0
0 commit comments