@@ -280,20 +280,6 @@ def save(self, fname, names=None, engine='auto', overwrite=True, display=False,
280
280
display : bool, optional
281
281
Whether or not to display which file is being worked on. Defaults to False.
282
282
283
- Notes
284
- -----
285
- When session's objects are saved in CSV files:
286
-
287
- - each array is saved in a separate file
288
- - all Axis objects are saved together in the same CSV file named __axes__.csv
289
- - all Group objects are saved together in the same CSV file named __groups__.csv
290
-
291
- When saving session's objects to an Excel file:
292
-
293
- - each array is saved in a separate sheet
294
- - all Axis objects are saved together in the same sheet named __axes__
295
- - all Group objects are saved together in the same sheet named __groups__
296
-
297
283
Examples
298
284
--------
299
285
>>> # axes
@@ -325,7 +311,10 @@ def save(self, fname, names=None, engine='auto', overwrite=True, display=False,
325
311
engine = ext_default_engine [ext ]
326
312
handler_cls = handler_classes [engine ]
327
313
handler = handler_cls (fname , overwrite )
328
- items = self .items ()
314
+ if engine != 'pandas_hdf' :
315
+ items = self .filter (kind = LArray ).items ()
316
+ else :
317
+ items = self .items ()
329
318
if names is not None :
330
319
names_set = set (names )
331
320
items = [(k , v ) for k , v in items if k in names_set ]
@@ -398,18 +387,17 @@ def to_globals(self, names=None, depth=0, warn=True, inplace=False):
398
387
399
388
def to_pickle (self , fname , names = None , overwrite = True , display = False , ** kwargs ):
400
389
"""
401
- Dumps LArray, Axis and Group objects from the current session to a file using pickle.
390
+ Dumps all array objects from the current session to a file using pickle.
402
391
403
392
WARNING: never load a pickle file (.pkl or .pickle) from an untrusted source, as it can lead to arbitrary code
404
393
execution.
405
394
406
395
Parameters
407
396
----------
408
397
fname : str
409
- Path of the file for the dump.
398
+ Path for the dump.
410
399
names : list of str or None, optional
411
- Names of LArray/Axis/Group objects to dump.
412
- Defaults to all objects present in the Session.
400
+ List of names of objects to dump. Defaults to all objects present in the Session.
413
401
overwrite: bool, optional
414
402
Whether or not to overwrite an existing file, if any.
415
403
If False, file is updated. Defaults to True.
@@ -418,22 +406,16 @@ def to_pickle(self, fname, names=None, overwrite=True, display=False, **kwargs):
418
406
419
407
Examples
420
408
--------
421
- >>> # axes
422
- >>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2") # doctest: +SKIP
423
- >>> # groups
424
- >>> a01 = a['a0,a1'] >> 'a01' # doctest: +SKIP
425
- >>> # arrays
426
- >>> arr1, arr2 = ndtest((a, b)), ndtest(a) # doctest: +SKIP
427
- >>> s = Session([('a', a), ('b', b), ('a01', a01), ('arr1', arr1), ('arr2', arr2)]) # doctest: +SKIP
428
-
409
+ >>> arr1, arr2, arr3 = ndtest((2, 2)), ndtest(4), ndtest((3, 2)) # doctest: +SKIP
410
+ >>> s = Session([('arr1', arr1), ('arr2', arr2), ('arr3', arr3)]) # doctest: +SKIP
429
411
430
412
Save all arrays
431
413
432
414
>>> s.to_pickle('output.pkl') # doctest: +SKIP
433
415
434
- Save only some objects
416
+ Save only some arrays
435
417
436
- >>> s.to_pickle('output.pkl', ['a ', 'b', 'arr1 ']) # doctest: +SKIP
418
+ >>> s.to_pickle('output.pkl', ['arr1 ', 'arr3 ']) # doctest: +SKIP
437
419
"""
438
420
self .save (fname , names , ext_default_engine ['pkl' ], overwrite , display , ** kwargs )
439
421
@@ -480,85 +462,61 @@ def to_hdf(self, fname, names=None, overwrite=True, display=False, **kwargs):
480
462
481
463
def to_excel (self , fname , names = None , overwrite = True , display = False , ** kwargs ):
482
464
"""
483
- Dumps LArray, Axis and Group objects from the current session to an Excel file.
465
+ Dumps all array objects from the current session to an Excel file.
484
466
485
467
Parameters
486
468
----------
487
469
fname : str
488
- Path of the file for the dump.
470
+ Path for the dump.
489
471
names : list of str or None, optional
490
- Names of LArray/Axis/Group objects to dump.
491
- Defaults to all objects present in the Session.
472
+ List of names of objects to dump. Defaults to all objects present in the Session.
492
473
overwrite: bool, optional
493
474
Whether or not to overwrite an existing file, if any. If False, file is updated. Defaults to True.
494
475
display : bool, optional
495
476
Whether or not to display which file is being worked on. Defaults to False.
496
477
497
- Notes
498
- -----
499
- - each array is saved in a separate sheet
500
- - all Axis objects are saved together in the same sheet named __axes__
501
- - all Group objects are saved together in the same sheet named __groups__
502
-
503
478
Examples
504
479
--------
505
- >>> # axes
506
- >>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2") # doctest: +SKIP
507
- >>> # groups
508
- >>> a01 = a['a0,a1'] >> 'a01' # doctest: +SKIP
509
- >>> # arrays
510
- >>> arr1, arr2 = ndtest((a, b)), ndtest(a) # doctest: +SKIP
511
- >>> s = Session([('a', a), ('b', b), ('a01', a01), ('arr1', arr1), ('arr2', arr2)]) # doctest: +SKIP
480
+ >>> arr1, arr2, arr3 = ndtest((2, 2)), ndtest(4), ndtest((3, 2)) # doctest: +SKIP
481
+ >>> s = Session([('arr1', arr1), ('arr2', arr2), ('arr3', arr3)]) # doctest: +SKIP
512
482
513
483
Save all arrays
514
484
515
485
>>> s.to_excel('output.xlsx') # doctest: +SKIP
516
486
517
- Save only some objects
487
+ Save only some arrays
518
488
519
- >>> s.to_excel('output.xlsx', ['a ', 'b', 'arr1 ']) # doctest: +SKIP
489
+ >>> s.to_excel('output.xlsx', ['arr1 ', 'arr3 ']) # doctest: +SKIP
520
490
"""
521
491
self .save (fname , names , ext_default_engine ['xlsx' ], overwrite , display , ** kwargs )
522
492
523
493
dump_excel = renamed_to (to_excel , 'dump_excel' )
524
494
525
495
def to_csv (self , fname , names = None , display = False , ** kwargs ):
526
496
"""
527
- Dumps LArray, Axis and Group objects from the current session to CSV files.
497
+ Dumps all array objects from the current session to CSV files.
528
498
529
499
Parameters
530
500
----------
531
501
fname : str
532
502
Path for the directory that will contain CSV files.
533
503
names : list of str or None, optional
534
- Names of LArray/Axis/Group objects to dump.
535
- Defaults to all objects present in the Session.
504
+ List of names of objects to dump. Defaults to all objects present in the Session.
536
505
display : bool, optional
537
506
Whether or not to display which file is being worked on. Defaults to False.
538
507
539
- Notes
540
- -----
541
- - each array is saved in a separate file
542
- - all Axis objects are saved together in the same CSV file named __axes__.csv
543
- - all Group objects are saved together in the same CSV file named __groups__.csv
544
-
545
508
Examples
546
509
--------
547
- >>> # axes
548
- >>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2") # doctest: +SKIP
549
- >>> # groups
550
- >>> a01 = a['a0,a1'] >> 'a01' # doctest: +SKIP
551
- >>> # arrays
552
- >>> arr1, arr2 = ndtest((a, b)), ndtest(a) # doctest: +SKIP
553
- >>> s = Session([('a', a), ('b', b), ('a01', a01), ('arr1', arr1), ('arr2', arr2)]) # doctest: +SKIP
510
+ >>> arr1, arr2, arr3 = ndtest((2, 2)), ndtest(4), ndtest((3, 2)) # doctest: +SKIP
511
+ >>> s = Session([('arr1', arr1), ('arr2', arr2), ('arr3', arr3)]) # doctest: +SKIP
554
512
555
513
Save all arrays
556
514
557
515
>>> s.to_csv('./Output') # doctest: +SKIP
558
516
559
517
Save only some arrays
560
518
561
- >>> s.to_csv('./Output', ['a ', 'b', 'arr1 ']) # doctest: +SKIP
519
+ >>> s.to_csv('./Output', ['arr1 ', 'arr3 ']) # doctest: +SKIP
562
520
"""
563
521
self .save (fname , names , ext_default_engine ['csv' ], display = display , ** kwargs )
564
522
0 commit comments