@@ -2441,78 +2441,6 @@ def format(item, just_pad_prec_spacer):
24412441 return text
24422442
24432443
2444- @cbook .deprecated ("2.2" , alternative = 'numpy.recarray.tofile' )
2445- def rec2csv (r , fname , delimiter = ',' , formatd = None , missing = '' ,
2446- missingd = None , withheader = True ):
2447- """
2448- Save the data from numpy recarray *r* into a
2449- comma-/space-/tab-delimited file. The record array dtype names
2450- will be used for column headers.
2451-
2452- *fname*: can be a filename or a file handle. Support for gzipped
2453- files is automatic, if the filename ends in '.gz'
2454-
2455- *withheader*: if withheader is False, do not write the attribute
2456- names in the first row
2457-
2458- for formatd type FormatFloat, we override the precision to store
2459- full precision floats in the CSV file
2460-
2461- See Also
2462- --------
2463- :func:`csv2rec`
2464- For information about *missing* and *missingd*, which can be used to
2465- fill in masked values into your CSV file.
2466- """
2467-
2468- delimiter = str (delimiter )
2469-
2470- if missingd is None :
2471- missingd = dict ()
2472-
2473- def with_mask (func ):
2474- def newfunc (val , mask , mval ):
2475- if mask :
2476- return mval
2477- else :
2478- return func (val )
2479- return newfunc
2480-
2481- if r .ndim != 1 :
2482- raise ValueError ('rec2csv only operates on 1 dimensional recarrays' )
2483-
2484- formatd = get_formatd (r , formatd )
2485- funcs = []
2486- for i , name in enumerate (r .dtype .names ):
2487- funcs .append (with_mask (csvformat_factory (formatd [name ]).tostr ))
2488-
2489- fh , opened = cbook .to_filehandle (fname , 'wb' , return_opened = True )
2490- writer = csv .writer (fh , delimiter = delimiter )
2491- header = r .dtype .names
2492- if withheader :
2493- writer .writerow (header )
2494-
2495- # Our list of specials for missing values
2496- mvals = []
2497- for name in header :
2498- mvals .append (missingd .get (name , missing ))
2499-
2500- ismasked = False
2501- if len (r ):
2502- row = r [0 ]
2503- ismasked = hasattr (row , '_fieldmask' )
2504-
2505- for row in r :
2506- if ismasked :
2507- row , rowmask = row .item (), row ._fieldmask .item ()
2508- else :
2509- rowmask = [False ] * len (row )
2510- writer .writerow ([func (val , mask , mval ) for func , val , mask , mval
2511- in zip (funcs , row , rowmask , mvals )])
2512- if opened :
2513- fh .close ()
2514-
2515-
25162444class GaussianKDE (object ):
25172445 """
25182446 Representation of a kernel-density estimate using Gaussian kernels.
0 commit comments