@@ -176,6 +176,7 @@ from pandas._typing import (
176
176
VoidDtypeArg ,
177
177
WriteBuffer ,
178
178
np_ndarray_anyint ,
179
+ np_ndarray_bool ,
179
180
np_ndarray_complex ,
180
181
np_ndarray_float ,
181
182
npt ,
@@ -187,6 +188,7 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
187
188
188
189
from pandas .plotting import PlotAccessor
189
190
191
+ _T_INT = TypeVar ("_T_INT" , bound = int )
190
192
_T_COMPLEX = TypeVar ("_T_COMPLEX" , bound = complex )
191
193
192
194
class _iLocIndexerSeries (_iLocIndexer , Generic [S1 ]):
@@ -1619,18 +1621,44 @@ class Series(IndexOpsMixin[S1], NDFrame):
1619
1621
def __add__ (self , other : Series [Never ]) -> Series : ...
1620
1622
@overload
1621
1623
def __add__ (
1622
- self : Series [int ], other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ]
1624
+ self : Series [bool ],
1625
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
1623
1626
) -> Series [_T_COMPLEX ]: ...
1624
1627
@overload
1625
- def __add__ (self : Series [int ], other : np_ndarray_anyint ) -> Series [int ]: ...
1628
+ def __add__ (self : Series [bool ], other : np_ndarray_bool ) -> Series [bool ]: ...
1629
+ @overload
1630
+ def __add__ (self : Series [bool ], other : np_ndarray_anyint ) -> Series [int ]: ...
1631
+ @overload
1632
+ def __add__ (self : Series [bool ], other : np_ndarray_float ) -> Series [float ]: ...
1633
+ @overload
1634
+ def __add__ (self : Series [bool ], other : np_ndarray_complex ) -> Series [complex ]: ...
1635
+ @overload
1636
+ def __add__ (
1637
+ self : Series [int ],
1638
+ other : (
1639
+ bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint | Series [bool ]
1640
+ ),
1641
+ ) -> Series [int ]: ...
1642
+ @overload
1643
+ def __add__ (
1644
+ self : Series [int ],
1645
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
1646
+ ) -> Series [_T_COMPLEX ]: ...
1626
1647
@overload
1627
1648
def __add__ (self : Series [int ], other : np_ndarray_float ) -> Series [float ]: ...
1628
1649
@overload
1629
1650
def __add__ (self : Series [int ], other : np_ndarray_complex ) -> Series [complex ]: ...
1630
1651
@overload
1631
1652
def __add__ (
1632
1653
self : Series [float ],
1633
- other : int | Sequence [int ] | np_ndarray_anyint | np_ndarray_float | Series [int ],
1654
+ other : (
1655
+ _T_INT
1656
+ | Sequence [_T_INT ]
1657
+ | np_ndarray_bool
1658
+ | np_ndarray_anyint
1659
+ | np_ndarray_float
1660
+ | Series [_T_INT ]
1661
+ ),
1634
1662
) -> Series [float ]: ...
1635
1663
@overload
1636
1664
def __add__ (
@@ -1643,12 +1671,12 @@ class Series(IndexOpsMixin[S1], NDFrame):
1643
1671
def __add__ (
1644
1672
self : Series [complex ],
1645
1673
other : (
1646
- _T_COMPLEX
1647
- | Sequence [_T_COMPLEX ]
1648
- | Series [_T_COMPLEX ]
1674
+ Sequence [_T_COMPLEX ]
1675
+ | np_ndarray_bool
1649
1676
| np_ndarray_anyint
1650
1677
| np_ndarray_float
1651
1678
| np_ndarray_complex
1679
+ | Series [_T_COMPLEX ]
1652
1680
),
1653
1681
) -> Series [complex ]: ...
1654
1682
@overload
@@ -1663,21 +1691,63 @@ class Series(IndexOpsMixin[S1], NDFrame):
1663
1691
) -> Series : ...
1664
1692
@overload
1665
1693
def add (
1666
- self : Series [int ],
1694
+ self : Series [bool ],
1667
1695
other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
1668
1696
level : Level | None = None ,
1669
1697
fill_value : float | None = None ,
1670
1698
axis : int = 0 ,
1671
1699
) -> Series [_T_COMPLEX ]: ...
1672
1700
@overload
1673
1701
def add (
1674
- self : Series [int ],
1702
+ self : Series [bool ],
1703
+ other : np_ndarray_bool ,
1704
+ level : Level | None = None ,
1705
+ fill_value : float | None = None ,
1706
+ axis : int = 0 ,
1707
+ ) -> Series [bool ]: ...
1708
+ @overload
1709
+ def add (
1710
+ self : Series [bool ],
1675
1711
other : np_ndarray_anyint ,
1676
1712
level : Level | None = None ,
1677
1713
fill_value : float | None = None ,
1678
1714
axis : int = 0 ,
1679
1715
) -> Series [int ]: ...
1680
1716
@overload
1717
+ def add (
1718
+ self : Series [bool ],
1719
+ other : np_ndarray_float ,
1720
+ level : Level | None = None ,
1721
+ fill_value : float | None = None ,
1722
+ axis : int = 0 ,
1723
+ ) -> Series [float ]: ...
1724
+ @overload
1725
+ def add (
1726
+ self : Series [bool ],
1727
+ other : np_ndarray_complex ,
1728
+ level : Level | None = None ,
1729
+ fill_value : float | None = None ,
1730
+ axis : int = 0 ,
1731
+ ) -> Series [complex ]: ...
1732
+ @overload
1733
+ def add (
1734
+ self : Series [int ],
1735
+ other : (
1736
+ bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint | Series [bool ]
1737
+ ),
1738
+ level : Level | None = None ,
1739
+ fill_value : float | None = None ,
1740
+ axis : int = 0 ,
1741
+ ) -> Series [int ]: ...
1742
+ @overload
1743
+ def add (
1744
+ self : Series [int ],
1745
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
1746
+ level : Level | None = None ,
1747
+ fill_value : float | None = None ,
1748
+ axis : int = 0 ,
1749
+ ) -> Series [_T_COMPLEX ]: ...
1750
+ @overload
1681
1751
def add (
1682
1752
self : Series [int ],
1683
1753
other : np_ndarray_float ,
@@ -1696,7 +1766,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
1696
1766
@overload
1697
1767
def add (
1698
1768
self : Series [float ],
1699
- other : int | Sequence [int ] | np_ndarray_anyint | np_ndarray_float | Series [int ],
1769
+ other : (
1770
+ _T_INT
1771
+ | Sequence [_T_INT ]
1772
+ | np_ndarray_bool
1773
+ | np_ndarray_anyint
1774
+ | np_ndarray_float
1775
+ | Series [_T_INT ]
1776
+ ),
1700
1777
level : Level | None = None ,
1701
1778
fill_value : float | None = None ,
1702
1779
axis : int = 0 ,
@@ -1722,6 +1799,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1722
1799
self : Series [complex ],
1723
1800
other : (
1724
1801
Sequence [_T_COMPLEX ]
1802
+ | np_ndarray_bool
1725
1803
| np_ndarray_anyint
1726
1804
| np_ndarray_float
1727
1805
| np_ndarray_complex
@@ -1743,18 +1821,39 @@ class Series(IndexOpsMixin[S1], NDFrame):
1743
1821
def __radd__ (self : Series [Never ], other : Scalar | _ListLike ) -> Series : ...
1744
1822
@overload
1745
1823
def __radd__ (
1746
- self : Series [int ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
1824
+ self : Series [bool ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
1747
1825
) -> Series [_T_COMPLEX ]: ...
1748
1826
@overload
1749
- def __radd__ (self : Series [int ], other : np_ndarray_anyint ) -> Series [int ]: ...
1827
+ def __radd__ (self : Series [bool ], other : np_ndarray_bool ) -> Series [bool ]: ...
1828
+ @overload
1829
+ def __radd__ (self : Series [bool ], other : np_ndarray_anyint ) -> Series [int ]: ...
1830
+ @overload
1831
+ def __radd__ (self : Series [bool ], other : np_ndarray_float ) -> Series [float ]: ...
1832
+ @overload
1833
+ def __radd__ (self : Series [bool ], other : np_ndarray_complex ) -> Series [complex ]: ...
1834
+ @overload
1835
+ def __radd__ (
1836
+ self : Series [int ],
1837
+ other : bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint ,
1838
+ ) -> Series [int ]: ...
1839
+ @overload
1840
+ def __radd__ (
1841
+ self : Series [int ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
1842
+ ) -> Series [_T_COMPLEX ]: ...
1750
1843
@overload
1751
1844
def __radd__ (self : Series [int ], other : np_ndarray_float ) -> Series [float ]: ...
1752
1845
@overload
1753
1846
def __radd__ (self : Series [int ], other : np_ndarray_complex ) -> Series [complex ]: ...
1754
1847
@overload
1755
1848
def __radd__ (
1756
1849
self : Series [float ],
1757
- other : int | Sequence [int ] | np_ndarray_anyint | np_ndarray_float ,
1850
+ other : (
1851
+ _T_INT
1852
+ | Sequence [_T_INT ]
1853
+ | np_ndarray_bool
1854
+ | np_ndarray_anyint
1855
+ | np_ndarray_float
1856
+ ),
1758
1857
) -> Series [float ]: ...
1759
1858
@overload
1760
1859
def __radd__ (
@@ -1766,7 +1865,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
1766
1865
def __radd__ (
1767
1866
self : Series [complex ],
1768
1867
other : (
1769
- np_ndarray_anyint
1868
+ np_ndarray_bool
1869
+ | np_ndarray_anyint
1770
1870
| np_ndarray_float
1771
1871
| np_ndarray_complex
1772
1872
| Sequence [_T_COMPLEX ]
@@ -1784,21 +1884,63 @@ class Series(IndexOpsMixin[S1], NDFrame):
1784
1884
) -> Series : ...
1785
1885
@overload
1786
1886
def radd (
1787
- self : Series [int ],
1887
+ self : Series [bool ],
1788
1888
other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
1789
1889
level : Level | None = None ,
1790
1890
fill_value : float | None = None ,
1791
1891
axis : int = 0 ,
1792
1892
) -> Series [_T_COMPLEX ]: ...
1793
1893
@overload
1794
1894
def radd (
1795
- self : Series [int ],
1895
+ self : Series [bool ],
1896
+ other : np_ndarray_bool ,
1897
+ level : Level | None = None ,
1898
+ fill_value : float | None = None ,
1899
+ axis : int = 0 ,
1900
+ ) -> Series [bool ]: ...
1901
+ @overload
1902
+ def radd (
1903
+ self : Series [bool ],
1796
1904
other : np_ndarray_anyint ,
1797
1905
level : Level | None = None ,
1798
1906
fill_value : float | None = None ,
1799
1907
axis : int = 0 ,
1800
1908
) -> Series [int ]: ...
1801
1909
@overload
1910
+ def radd (
1911
+ self : Series [bool ],
1912
+ other : np_ndarray_float ,
1913
+ level : Level | None = None ,
1914
+ fill_value : float | None = None ,
1915
+ axis : int = 0 ,
1916
+ ) -> Series [float ]: ...
1917
+ @overload
1918
+ def radd (
1919
+ self : Series [bool ],
1920
+ other : np_ndarray_complex ,
1921
+ level : Level | None = None ,
1922
+ fill_value : float | None = None ,
1923
+ axis : int = 0 ,
1924
+ ) -> Series [complex ]: ...
1925
+ @overload
1926
+ def radd (
1927
+ self : Series [int ],
1928
+ other : (
1929
+ bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint | Series [bool ]
1930
+ ),
1931
+ level : Level | None = None ,
1932
+ fill_value : float | None = None ,
1933
+ axis : int = 0 ,
1934
+ ) -> Series [int ]: ...
1935
+ @overload
1936
+ def radd (
1937
+ self : Series [int ],
1938
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
1939
+ level : Level | None = None ,
1940
+ fill_value : float | None = None ,
1941
+ axis : int = 0 ,
1942
+ ) -> Series [_T_COMPLEX ]: ...
1943
+ @overload
1802
1944
def radd (
1803
1945
self : Series [int ],
1804
1946
other : np_ndarray_float ,
@@ -1817,7 +1959,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
1817
1959
@overload
1818
1960
def radd (
1819
1961
self : Series [float ],
1820
- other : int | Sequence [int ] | np_ndarray_anyint | np_ndarray_float | Series [int ],
1962
+ other : (
1963
+ _T_INT
1964
+ | Sequence [_T_INT ]
1965
+ | np_ndarray_bool
1966
+ | np_ndarray_anyint
1967
+ | np_ndarray_float
1968
+ | Series [_T_INT ]
1969
+ ),
1821
1970
level : Level | None = None ,
1822
1971
fill_value : float | None = None ,
1823
1972
axis : int = 0 ,
@@ -1843,6 +1992,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1843
1992
self : Series [complex ],
1844
1993
other : (
1845
1994
Sequence [_T_COMPLEX ]
1995
+ | np_ndarray_bool
1846
1996
| np_ndarray_anyint
1847
1997
| np_ndarray_float
1848
1998
| np_ndarray_complex
0 commit comments