@@ -1581,145 +1581,6 @@ def test_multiindex_from_frame(self):
1581
1581
psdf = ps .from_pandas (pdf )
1582
1582
self .assert_eq (ps .MultiIndex .from_frame (psdf ), pd .MultiIndex .from_frame (pdf ))
1583
1583
1584
- def test_is_type_compatible (self ):
1585
- data_types = ["integer" , "floating" , "string" , "boolean" ]
1586
- # Integer
1587
- pidx = pd .Index ([1 , 2 , 3 ])
1588
- psidx = ps .from_pandas (pidx )
1589
- # is_type_compatible is removed from pandas 2.0.0.
1590
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1591
- expected_results = [True , False , False , False ]
1592
- for data_type , expected_result in zip (data_types , expected_results ):
1593
- self .assert_eq (psidx .is_type_compatible (data_type ), expected_result )
1594
- else :
1595
- for data_type in data_types :
1596
- self .assert_eq (
1597
- pidx .is_type_compatible (data_type ), psidx .is_type_compatible (data_type )
1598
- )
1599
-
1600
- # Floating
1601
- pidx = pd .Index ([1.0 , 2.0 , 3.0 ])
1602
- psidx = ps .from_pandas (pidx )
1603
- # is_type_compatible is removed from pandas 2.0.0.
1604
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1605
- expected_results = [False , True , False , False ]
1606
- for data_type , expected_result in zip (data_types , expected_results ):
1607
- self .assert_eq (psidx .is_type_compatible (data_type ), expected_result )
1608
- else :
1609
- for data_type in data_types :
1610
- self .assert_eq (
1611
- pidx .is_type_compatible (data_type ), psidx .is_type_compatible (data_type )
1612
- )
1613
-
1614
- # String
1615
- pidx = pd .Index (["a" , "b" , "c" ])
1616
- psidx = ps .from_pandas (pidx )
1617
- # is_type_compatible is removed from pandas 2.0.0.
1618
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1619
- expected_results = [False , False , True , False ]
1620
- for data_type , expected_result in zip (data_types , expected_results ):
1621
- self .assert_eq (psidx .is_type_compatible (data_type ), expected_result )
1622
- else :
1623
- for data_type in data_types :
1624
- self .assert_eq (
1625
- pidx .is_type_compatible (data_type ), psidx .is_type_compatible (data_type )
1626
- )
1627
-
1628
- # Boolean
1629
- pidx = pd .Index ([True , False , True , False ])
1630
- psidx = ps .from_pandas (pidx )
1631
- # is_type_compatible is removed from pandas 2.0.0.
1632
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1633
- expected_results = [False , False , False , True ]
1634
- for data_type , expected_result in zip (data_types , expected_results ):
1635
- self .assert_eq (psidx .is_type_compatible (data_type ), expected_result )
1636
- else :
1637
- for data_type in data_types :
1638
- self .assert_eq (
1639
- pidx .is_type_compatible (data_type ), psidx .is_type_compatible (data_type )
1640
- )
1641
-
1642
- # MultiIndex
1643
- pmidx = pd .MultiIndex .from_tuples ([("a" , "x" )])
1644
- psmidx = ps .from_pandas (pmidx )
1645
- # is_type_compatible is removed from pandas 2.0.0.
1646
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1647
- expected_results = [False , False , False , False ]
1648
- for data_type , expected_result in zip (data_types , expected_results ):
1649
- self .assert_eq (psmidx .is_type_compatible (data_type ), expected_result )
1650
- else :
1651
- for data_type in data_types :
1652
- self .assert_eq (
1653
- pmidx .is_type_compatible (data_type ), psmidx .is_type_compatible (data_type )
1654
- )
1655
-
1656
- def test_asi8 (self ):
1657
- # Integer
1658
- pidx = pd .Index ([1 , 2 , 3 ])
1659
- psidx = ps .from_pandas (pidx )
1660
- # asi8 is removed from pandas 2.0.0.
1661
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1662
- self .assert_eq (np .array (pidx ), psidx .asi8 )
1663
- self .assert_eq (np .array (pidx .astype ("int" )), psidx .astype ("int" ).asi8 )
1664
- self .assert_eq (np .array (pidx .astype ("int16" )), psidx .astype ("int16" ).asi8 )
1665
- self .assert_eq (np .array (pidx .astype ("int8" )), psidx .astype ("int8" ).asi8 )
1666
- else :
1667
- self .assert_eq (pidx .asi8 , psidx .asi8 )
1668
- self .assert_eq (pidx .astype ("int" ).asi8 , psidx .astype ("int" ).asi8 )
1669
- self .assert_eq (pidx .astype ("int16" ).asi8 , psidx .astype ("int16" ).asi8 )
1670
- self .assert_eq (pidx .astype ("int8" ).asi8 , psidx .astype ("int8" ).asi8 )
1671
-
1672
- # Integer with missing value
1673
- pidx = pd .Index ([1 , 2 , None , 4 , 5 ])
1674
- psidx = ps .from_pandas (pidx )
1675
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1676
- self .assert_eq (None , psidx .asi8 )
1677
- else :
1678
- self .assert_eq (pidx .asi8 , psidx .asi8 )
1679
-
1680
- # Datetime
1681
- pidx = pd .date_range (end = "1/1/2018" , periods = 3 )
1682
- psidx = ps .from_pandas (pidx )
1683
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1684
- self .assert_eq (
1685
- np .array ([1514592000000000000 , 1514678400000000000 , 1514764800000000000 ]),
1686
- psidx .asi8 ,
1687
- )
1688
- else :
1689
- self .assert_eq (pidx .asi8 , psidx .asi8 )
1690
-
1691
- # Floating
1692
- pidx = pd .Index ([1.0 , 2.0 , 3.0 ])
1693
- psidx = ps .from_pandas (pidx )
1694
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1695
- self .assert_eq (None , psidx .asi8 )
1696
- else :
1697
- self .assert_eq (pidx .asi8 , psidx .asi8 )
1698
-
1699
- # String
1700
- pidx = pd .Index (["a" , "b" , "c" ])
1701
- psidx = ps .from_pandas (pidx )
1702
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1703
- self .assert_eq (None , psidx .asi8 )
1704
- else :
1705
- self .assert_eq (pidx .asi8 , psidx .asi8 )
1706
-
1707
- # Boolean
1708
- pidx = pd .Index ([True , False , True , False ])
1709
- psidx = ps .from_pandas (pidx )
1710
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1711
- self .assert_eq (None , psidx .asi8 )
1712
- else :
1713
- self .assert_eq (pidx .asi8 , psidx .asi8 )
1714
-
1715
- # MultiIndex
1716
- pmidx = pd .MultiIndex .from_tuples ([(1 , 2 )])
1717
- psmidx = ps .from_pandas (pmidx )
1718
- if LooseVersion (pd .__version__ ) >= LooseVersion ("2.0.0" ):
1719
- self .assert_eq (None , psmidx .asi8 )
1720
- else :
1721
- self .assert_eq (pmidx .asi8 , psmidx .asi8 )
1722
-
1723
1584
def test_index_is_unique (self ):
1724
1585
indexes = [("a" , "b" , "c" ), ("a" , "a" , "c" ), (1 , 3 , 3 ), (1 , 2 , 3 )]
1725
1586
names = [None , "ks" , "ks" , None ]
0 commit comments