@@ -342,8 +342,8 @@ def test_iget(self):
342
342
def test_set (self ):
343
343
mgr = create_mgr ("a,b,c: int" , item_shape = (3 ,))
344
344
345
- mgr .set ( "d" , np .array (["foo" ] * 3 ))
346
- mgr .set ( "b" , np .array (["bar" ] * 3 ))
345
+ mgr .insert ( len ( mgr . items ), "d" , np .array (["foo" ] * 3 ))
346
+ mgr .iset ( 1 , np .array (["bar" ] * 3 ))
347
347
tm .assert_numpy_array_equal (mgr .iget (0 ).internal_values (), np .array ([0 ] * 3 ))
348
348
tm .assert_numpy_array_equal (
349
349
mgr .iget (1 ).internal_values (), np .array (["bar" ] * 3 , dtype = np .object_ )
@@ -354,22 +354,22 @@ def test_set(self):
354
354
)
355
355
356
356
def test_set_change_dtype (self , mgr ):
357
- mgr .set ( "baz" , np .zeros (N , dtype = bool ))
357
+ mgr .insert ( len ( mgr . items ), "baz" , np .zeros (N , dtype = bool ))
358
358
359
- mgr .set ( "baz" , np .repeat ("foo" , N ))
359
+ mgr .iset ( mgr . items . get_loc ( "baz" ) , np .repeat ("foo" , N ))
360
360
idx = mgr .items .get_loc ("baz" )
361
361
assert mgr .iget (idx ).dtype == np .object_
362
362
363
363
mgr2 = mgr .consolidate ()
364
- mgr2 .set ( "baz" , np .repeat ("foo" , N ))
364
+ mgr2 .iset ( mgr2 . items . get_loc ( "baz" ) , np .repeat ("foo" , N ))
365
365
idx = mgr2 .items .get_loc ("baz" )
366
366
assert mgr2 .iget (idx ).dtype == np .object_
367
367
368
- mgr2 .set ( "quux" , tm .randn (N ).astype (int ))
368
+ mgr2 .insert ( len ( mgr2 . items ), "quux" , tm .randn (N ).astype (int ))
369
369
idx = mgr2 .items .get_loc ("quux" )
370
370
assert mgr2 .iget (idx ).dtype == np .int_
371
371
372
- mgr2 .set ( "quux" , tm .randn (N ))
372
+ mgr2 .iset ( mgr2 . items . get_loc ( "quux" ) , tm .randn (N ))
373
373
assert mgr2 .iget (idx ).dtype == np .float_
374
374
375
375
def test_copy (self , mgr ):
@@ -496,9 +496,9 @@ def _compare(old_mgr, new_mgr):
496
496
497
497
# convert
498
498
mgr = create_mgr ("a,b,foo: object; f: i8; g: f8" )
499
- mgr .set ( "a" , np .array (["1" ] * N , dtype = np .object_ ))
500
- mgr .set ( "b" , np .array (["2." ] * N , dtype = np .object_ ))
501
- mgr .set ( "foo" , np .array (["foo." ] * N , dtype = np .object_ ))
499
+ mgr .iset ( 0 , np .array (["1" ] * N , dtype = np .object_ ))
500
+ mgr .iset ( 1 , np .array (["2." ] * N , dtype = np .object_ ))
501
+ mgr .iset ( 2 , np .array (["foo." ] * N , dtype = np .object_ ))
502
502
new_mgr = mgr .convert (numeric = True )
503
503
assert new_mgr .iget (0 ).dtype == np .int64
504
504
assert new_mgr .iget (1 ).dtype == np .float64
@@ -509,9 +509,9 @@ def _compare(old_mgr, new_mgr):
509
509
mgr = create_mgr (
510
510
"a,b,foo: object; f: i4; bool: bool; dt: datetime; i: i8; g: f8; h: f2"
511
511
)
512
- mgr .set ( "a" , np .array (["1" ] * N , dtype = np .object_ ))
513
- mgr .set ( "b" , np .array (["2." ] * N , dtype = np .object_ ))
514
- mgr .set ( "foo" , np .array (["foo." ] * N , dtype = np .object_ ))
512
+ mgr .iset ( 0 , np .array (["1" ] * N , dtype = np .object_ ))
513
+ mgr .iset ( 1 , np .array (["2." ] * N , dtype = np .object_ ))
514
+ mgr .iset ( 2 , np .array (["foo." ] * N , dtype = np .object_ ))
515
515
new_mgr = mgr .convert (numeric = True )
516
516
assert new_mgr .iget (0 ).dtype == np .int64
517
517
assert new_mgr .iget (1 ).dtype == np .float64
@@ -599,11 +599,11 @@ def test_interleave_dtype(self, mgr_string, dtype):
599
599
assert mgr .as_array ().dtype == "object"
600
600
601
601
def test_consolidate_ordering_issues (self , mgr ):
602
- mgr .set ( "f" , tm .randn (N ))
603
- mgr .set ( "d" , tm .randn (N ))
604
- mgr .set ( "b" , tm .randn (N ))
605
- mgr .set ( "g" , tm .randn (N ))
606
- mgr .set ( "h" , tm .randn (N ))
602
+ mgr .iset ( mgr . items . get_loc ( "f" ) , tm .randn (N ))
603
+ mgr .iset ( mgr . items . get_loc ( "d" ) , tm .randn (N ))
604
+ mgr .iset ( mgr . items . get_loc ( "b" ) , tm .randn (N ))
605
+ mgr .iset ( mgr . items . get_loc ( "g" ) , tm .randn (N ))
606
+ mgr .iset ( mgr . items . get_loc ( "h" ) , tm .randn (N ))
607
607
608
608
# we have datetime/tz blocks in mgr
609
609
cons = mgr .consolidate ()
@@ -641,7 +641,7 @@ def test_get_numeric_data(self):
641
641
"str: object; bool: bool; obj: object; dt: datetime" ,
642
642
item_shape = (3 ,),
643
643
)
644
- mgr .set ( "obj" , np .array ([1 , 2 , 3 ], dtype = np .object_ ))
644
+ mgr .iset ( 5 , np .array ([1 , 2 , 3 ], dtype = np .object_ ))
645
645
646
646
numeric = mgr .get_numeric_data ()
647
647
tm .assert_index_equal (
@@ -653,7 +653,7 @@ def test_get_numeric_data(self):
653
653
)
654
654
655
655
# Check sharing
656
- numeric .set ( "float" , np .array ([100.0 , 200.0 , 300.0 ]))
656
+ numeric .iset ( numeric . items . get_loc ( "float" ) , np .array ([100.0 , 200.0 , 300.0 ]))
657
657
tm .assert_almost_equal (
658
658
mgr .iget (mgr .items .get_loc ("float" )).internal_values (),
659
659
np .array ([100.0 , 200.0 , 300.0 ]),
@@ -663,7 +663,9 @@ def test_get_numeric_data(self):
663
663
tm .assert_index_equal (
664
664
numeric .items , pd .Index (["int" , "float" , "complex" , "bool" ])
665
665
)
666
- numeric2 .set ("float" , np .array ([1000.0 , 2000.0 , 3000.0 ]))
666
+ numeric2 .iset (
667
+ numeric2 .items .get_loc ("float" ), np .array ([1000.0 , 2000.0 , 3000.0 ])
668
+ )
667
669
tm .assert_almost_equal (
668
670
mgr .iget (mgr .items .get_loc ("float" )).internal_values (),
669
671
np .array ([100.0 , 200.0 , 300.0 ]),
@@ -675,7 +677,7 @@ def test_get_bool_data(self):
675
677
"str: object; bool: bool; obj: object; dt: datetime" ,
676
678
item_shape = (3 ,),
677
679
)
678
- mgr .set ( "obj" , np .array ([True , False , True ], dtype = np .object_ ))
680
+ mgr .iset ( 6 , np .array ([True , False , True ], dtype = np .object_ ))
679
681
680
682
bools = mgr .get_bool_data ()
681
683
tm .assert_index_equal (bools .items , pd .Index (["bool" ]))
@@ -684,15 +686,15 @@ def test_get_bool_data(self):
684
686
bools .iget (bools .items .get_loc ("bool" )).internal_values (),
685
687
)
686
688
687
- bools .set ( "bool" , np .array ([True , False , True ]))
689
+ bools .iset ( 0 , np .array ([True , False , True ]))
688
690
tm .assert_numpy_array_equal (
689
691
mgr .iget (mgr .items .get_loc ("bool" )).internal_values (),
690
692
np .array ([True , False , True ]),
691
693
)
692
694
693
695
# Check sharing
694
696
bools2 = mgr .get_bool_data (copy = True )
695
- bools2 .set ( "bool" , np .array ([False , True , False ]))
697
+ bools2 .iset ( 0 , np .array ([False , True , False ]))
696
698
tm .assert_numpy_array_equal (
697
699
mgr .iget (mgr .items .get_loc ("bool" )).internal_values (),
698
700
np .array ([True , False , True ]),
0 commit comments