Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/pandas/core/strings/base.py: 66%

161 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1from __future__ import annotations 

2 

3import abc 

4from collections.abc import Callable # noqa: PDF001 

5import re 

6from typing import TYPE_CHECKING 

7 

8import numpy as np 

9 

10from pandas._typing import Scalar 

11 

12if TYPE_CHECKING: 12 ↛ 13line 12 didn't jump to line 13, because the condition on line 12 was never true

13 from pandas import Series 

14 

15 

16class BaseStringArrayMethods(abc.ABC): 

17 """ 

18 Base class for extension arrays implementing string methods. 

19 

20 This is where our ExtensionArrays can override the implementation of 

21 Series.str.<method>. We don't expect this to work with 

22 3rd-party extension arrays. 

23 

24 * User calls Series.str.<method> 

25 * pandas extracts the extension array from the Series 

26 * pandas calls ``extension_array._str_<method>(*args, **kwargs)`` 

27 * pandas wraps the result, to return to the user. 

28 

29 See :ref:`Series.str` for the docstring of each method. 

30 """ 

31 

32 def _str_getitem(self, key): 

33 if isinstance(key, slice): 

34 return self._str_slice(start=key.start, stop=key.stop, step=key.step) 

35 else: 

36 return self._str_get(key) 

37 

38 @abc.abstractmethod 

39 def _str_count(self, pat, flags=0): 

40 pass 

41 

42 @abc.abstractmethod 

43 def _str_pad(self, width, side="left", fillchar=" "): 

44 pass 

45 

46 @abc.abstractmethod 

47 def _str_contains(self, pat, case=True, flags=0, na=None, regex=True): 

48 pass 

49 

50 @abc.abstractmethod 

51 def _str_startswith(self, pat, na=None): 

52 pass 

53 

54 @abc.abstractmethod 

55 def _str_endswith(self, pat, na=None): 

56 pass 

57 

58 @abc.abstractmethod 

59 def _str_replace( 

60 self, 

61 pat: str | re.Pattern, 

62 repl: str | Callable, 

63 n: int = -1, 

64 case: bool = True, 

65 flags: int = 0, 

66 regex: bool = True, 

67 ): 

68 pass 

69 

70 @abc.abstractmethod 

71 def _str_repeat(self, repeats): 

72 pass 

73 

74 @abc.abstractmethod 

75 def _str_match( 

76 self, pat: str, case: bool = True, flags: int = 0, na: Scalar = np.nan 

77 ): 

78 pass 

79 

80 @abc.abstractmethod 

81 def _str_fullmatch( 

82 self, 

83 pat: str | re.Pattern, 

84 case: bool = True, 

85 flags: int = 0, 

86 na: Scalar = np.nan, 

87 ): 

88 pass 

89 

90 @abc.abstractmethod 

91 def _str_encode(self, encoding, errors="strict"): 

92 pass 

93 

94 @abc.abstractmethod 

95 def _str_find(self, sub, start=0, end=None): 

96 pass 

97 

98 @abc.abstractmethod 

99 def _str_rfind(self, sub, start=0, end=None): 

100 pass 

101 

102 @abc.abstractmethod 

103 def _str_findall(self, pat, flags=0): 

104 pass 

105 

106 @abc.abstractmethod 

107 def _str_get(self, i): 

108 pass 

109 

110 @abc.abstractmethod 

111 def _str_index(self, sub, start=0, end=None): 

112 pass 

113 

114 @abc.abstractmethod 

115 def _str_rindex(self, sub, start=0, end=None): 

116 pass 

117 

118 @abc.abstractmethod 

119 def _str_join(self, sep): 

120 pass 

121 

122 @abc.abstractmethod 

123 def _str_partition(self, sep, expand): 

124 pass 

125 

126 @abc.abstractmethod 

127 def _str_rpartition(self, sep, expand): 

128 pass 

129 

130 @abc.abstractmethod 

131 def _str_len(self): 

132 pass 

133 

134 @abc.abstractmethod 

135 def _str_slice(self, start=None, stop=None, step=None): 

136 pass 

137 

138 @abc.abstractmethod 

139 def _str_slice_replace(self, start=None, stop=None, repl=None): 

140 pass 

141 

142 @abc.abstractmethod 

143 def _str_translate(self, table): 

144 pass 

145 

146 @abc.abstractmethod 

147 def _str_wrap(self, width, **kwargs): 

148 pass 

149 

150 @abc.abstractmethod 

151 def _str_get_dummies(self, sep="|"): 

152 pass 

153 

154 @abc.abstractmethod 

155 def _str_isalnum(self): 

156 pass 

157 

158 @abc.abstractmethod 

159 def _str_isalpha(self): 

160 pass 

161 

162 @abc.abstractmethod 

163 def _str_isdecimal(self): 

164 pass 

165 

166 @abc.abstractmethod 

167 def _str_isdigit(self): 

168 pass 

169 

170 @abc.abstractmethod 

171 def _str_islower(self): 

172 pass 

173 

174 @abc.abstractmethod 

175 def _str_isnumeric(self): 

176 pass 

177 

178 @abc.abstractmethod 

179 def _str_isspace(self): 

180 pass 

181 

182 @abc.abstractmethod 

183 def _str_istitle(self): 

184 pass 

185 

186 @abc.abstractmethod 

187 def _str_isupper(self): 

188 pass 

189 

190 @abc.abstractmethod 

191 def _str_capitalize(self): 

192 pass 

193 

194 @abc.abstractmethod 

195 def _str_casefold(self): 

196 pass 

197 

198 @abc.abstractmethod 

199 def _str_title(self): 

200 pass 

201 

202 @abc.abstractmethod 

203 def _str_swapcase(self): 

204 pass 

205 

206 @abc.abstractmethod 

207 def _str_lower(self): 

208 pass 

209 

210 @abc.abstractmethod 

211 def _str_upper(self): 

212 pass 

213 

214 @abc.abstractmethod 

215 def _str_normalize(self, form): 

216 pass 

217 

218 @abc.abstractmethod 

219 def _str_strip(self, to_strip=None): 

220 pass 

221 

222 @abc.abstractmethod 

223 def _str_lstrip(self, to_strip=None): 

224 pass 

225 

226 @abc.abstractmethod 

227 def _str_rstrip(self, to_strip=None): 

228 pass 

229 

230 @abc.abstractmethod 

231 def _str_removeprefix(self, prefix: str) -> Series: 

232 pass 

233 

234 @abc.abstractmethod 

235 def _str_removesuffix(self, suffix: str) -> Series: 

236 pass 

237 

238 @abc.abstractmethod 

239 def _str_split(self, pat=None, n=-1, expand=False): 

240 pass 

241 

242 @abc.abstractmethod 

243 def _str_rsplit(self, pat=None, n=-1): 

244 pass 

245 

246 @abc.abstractmethod 

247 def _str_extract(self, pat: str, flags: int = 0, expand: bool = True): 

248 pass