Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pandas/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

27 statements  

1from __future__ import annotations 

2 

3__docformat__ = "restructuredtext" 

4 

5# Let users know if they're missing any of our hard dependencies 

6# except tzdata (see https://github.com/pandas-dev/pandas/issues/63264) 

7_hard_dependencies = ("numpy", "dateutil") 

8 

9for _dependency in _hard_dependencies: 

10 try: 

11 __import__(_dependency) 

12 except ImportError as _e: # pragma: no cover 

13 raise ImportError( 

14 f"Unable to import required dependency {_dependency}. " 

15 "Please see the traceback for details." 

16 ) from _e 

17 

18del _hard_dependencies, _dependency 

19 

20try: 

21 # numpy compat 

22 from pandas.compat import ( 

23 is_numpy_dev as _is_numpy_dev, # pyright: ignore[reportUnusedImport] # noqa: F401 

24 ) 

25except ImportError as _err: # pragma: no cover 

26 _module = _err.name 

27 raise ImportError( 

28 f"C extension: {_module} not built. If you want to import " 

29 "pandas from the source directory, you may need to run " 

30 "'python -m pip install -ve . --no-build-isolation -Ceditable-verbose=true' " 

31 "to build the C extensions first." 

32 ) from _err 

33 

34from pandas._config import ( 

35 get_option, 

36 set_option, 

37 reset_option, 

38 describe_option, 

39 option_context, 

40 options, 

41) 

42 

43# let init-time option registration happen 

44import pandas.core.config_init # pyright: ignore[reportUnusedImport] # noqa: F401 

45 

46from pandas.core.api import ( 

47 # dtype 

48 ArrowDtype, 

49 Int8Dtype, 

50 Int16Dtype, 

51 Int32Dtype, 

52 Int64Dtype, 

53 UInt8Dtype, 

54 UInt16Dtype, 

55 UInt32Dtype, 

56 UInt64Dtype, 

57 Float32Dtype, 

58 Float64Dtype, 

59 CategoricalDtype, 

60 PeriodDtype, 

61 IntervalDtype, 

62 DatetimeTZDtype, 

63 StringDtype, 

64 BooleanDtype, 

65 # missing 

66 NA, 

67 isna, 

68 isnull, 

69 notna, 

70 notnull, 

71 # indexes 

72 Index, 

73 CategoricalIndex, 

74 RangeIndex, 

75 MultiIndex, 

76 IntervalIndex, 

77 TimedeltaIndex, 

78 DatetimeIndex, 

79 PeriodIndex, 

80 IndexSlice, 

81 # tseries 

82 NaT, 

83 Period, 

84 period_range, 

85 Timedelta, 

86 timedelta_range, 

87 Timestamp, 

88 date_range, 

89 bdate_range, 

90 Interval, 

91 interval_range, 

92 DateOffset, 

93 # conversion 

94 to_numeric, 

95 to_datetime, 

96 to_timedelta, 

97 # misc 

98 Flags, 

99 Grouper, 

100 factorize, 

101 unique, 

102 NamedAgg, 

103 NamedFunc, 

104 array, 

105 Categorical, 

106 set_eng_float_format, 

107 Series, 

108 DataFrame, 

109) 

110from pandas.core.col import col 

111 

112from pandas.core.dtypes.dtypes import SparseDtype 

113 

114from pandas.tseries.api import infer_freq 

115from pandas.tseries import offsets 

116 

117from pandas.core.computation.api import eval 

118 

119from pandas.core.reshape.api import ( 

120 concat, 

121 lreshape, 

122 melt, 

123 wide_to_long, 

124 merge, 

125 merge_asof, 

126 merge_ordered, 

127 crosstab, 

128 pivot, 

129 pivot_table, 

130 get_dummies, 

131 from_dummies, 

132 cut, 

133 qcut, 

134) 

135 

136from pandas import api, arrays, errors, io, plotting, tseries 

137from pandas import testing 

138from pandas.util._print_versions import show_versions 

139 

140from pandas.io.api import ( 

141 # excel 

142 ExcelFile, 

143 ExcelWriter, 

144 read_excel, 

145 # parsers 

146 read_csv, 

147 read_fwf, 

148 read_table, 

149 # pickle 

150 read_pickle, 

151 to_pickle, 

152 # pytables 

153 HDFStore, 

154 read_hdf, 

155 # sql 

156 read_sql, 

157 read_sql_query, 

158 read_sql_table, 

159 # misc 

160 read_clipboard, 

161 read_parquet, 

162 read_orc, 

163 read_feather, 

164 read_html, 

165 read_xml, 

166 read_json, 

167 read_stata, 

168 read_sas, 

169 read_spss, 

170 read_iceberg, 

171) 

172 

173from pandas.io.json._normalize import json_normalize 

174 

175from pandas.util._tester import test 

176 

177# use the closest tagged version if possible 

178from pandas._version_meson import ( # pyright: ignore [reportMissingImports] 

179 __version__, 

180 __git_version__, 

181) 

182 

183 

184# module level doc-string 

185__doc__ = """ 

186pandas - a powerful data analysis and manipulation library for Python 

187===================================================================== 

188 

189**pandas** is a Python package providing fast, flexible, and expressive data 

190structures designed to make working with "relational" or "labeled" data both 

191easy and intuitive. It aims to be the fundamental high-level building block for 

192doing practical, **real world** data analysis in Python. Additionally, it has 

193the broader goal of becoming **the most powerful and flexible open source data 

194analysis / manipulation tool available in any language**. It is already well on 

195its way toward this goal. 

196 

197Main Features 

198------------- 

199Here are just a few of the things that pandas does well: 

200 

201 - Easy handling of missing data in floating point as well as non-floating 

202 point data. 

203 - Size mutability: columns can be inserted and deleted from DataFrame and 

204 higher dimensional objects 

205 - Automatic and explicit data alignment: objects can be explicitly aligned 

206 to a set of labels, or the user can simply ignore the labels and let 

207 `Series`, `DataFrame`, etc. automatically align the data for you in 

208 computations. 

209 - Powerful, flexible group by functionality to perform split-apply-combine 

210 operations on data sets, for both aggregating and transforming data. 

211 - Make it easy to convert ragged, differently-indexed data in other Python 

212 and NumPy data structures into DataFrame objects. 

213 - Intelligent label-based slicing, fancy indexing, and subsetting of large 

214 data sets. 

215 - Intuitive merging and joining data sets. 

216 - Flexible reshaping and pivoting of data sets. 

217 - Hierarchical labeling of axes (possible to have multiple labels per tick). 

218 - Robust IO tools for loading data from flat files (CSV and delimited), 

219 Excel files, databases, and saving/loading data from the ultrafast HDF5 

220 format. 

221 - Time series-specific functionality: date range generation and frequency 

222 conversion, moving window statistics, date shifting and lagging. 

223""" 

224 

225# Use __all__ to let type checkers know what is part of the public API. 

226# Pandas is not (yet) a py.typed library: the public API is determined 

227# based on the documentation. 

228__all__ = [ 

229 "NA", 

230 "ArrowDtype", 

231 "BooleanDtype", 

232 "Categorical", 

233 "CategoricalDtype", 

234 "CategoricalIndex", 

235 "DataFrame", 

236 "DateOffset", 

237 "DatetimeIndex", 

238 "DatetimeTZDtype", 

239 "ExcelFile", 

240 "ExcelWriter", 

241 "Flags", 

242 "Float32Dtype", 

243 "Float64Dtype", 

244 "Grouper", 

245 "HDFStore", 

246 "Index", 

247 "IndexSlice", 

248 "Int8Dtype", 

249 "Int16Dtype", 

250 "Int32Dtype", 

251 "Int64Dtype", 

252 "Interval", 

253 "IntervalDtype", 

254 "IntervalIndex", 

255 "MultiIndex", 

256 "NaT", 

257 "NamedAgg", 

258 "NamedFunc", 

259 "Period", 

260 "PeriodDtype", 

261 "PeriodIndex", 

262 "RangeIndex", 

263 "Series", 

264 "SparseDtype", 

265 "StringDtype", 

266 "Timedelta", 

267 "TimedeltaIndex", 

268 "Timestamp", 

269 "UInt8Dtype", 

270 "UInt16Dtype", 

271 "UInt32Dtype", 

272 "UInt64Dtype", 

273 "__git_version__", 

274 "__version__", 

275 "api", 

276 "array", 

277 "arrays", 

278 "bdate_range", 

279 "col", 

280 "concat", 

281 "crosstab", 

282 "cut", 

283 "date_range", 

284 "describe_option", 

285 "errors", 

286 "eval", 

287 "factorize", 

288 "from_dummies", 

289 "get_dummies", 

290 "get_option", 

291 "infer_freq", 

292 "interval_range", 

293 "io", 

294 "isna", 

295 "isnull", 

296 "json_normalize", 

297 "lreshape", 

298 "melt", 

299 "merge", 

300 "merge_asof", 

301 "merge_ordered", 

302 "notna", 

303 "notnull", 

304 "offsets", 

305 "option_context", 

306 "options", 

307 "period_range", 

308 "pivot", 

309 "pivot_table", 

310 "plotting", 

311 "qcut", 

312 "read_clipboard", 

313 "read_csv", 

314 "read_excel", 

315 "read_feather", 

316 "read_fwf", 

317 "read_hdf", 

318 "read_html", 

319 "read_iceberg", 

320 "read_json", 

321 "read_orc", 

322 "read_parquet", 

323 "read_pickle", 

324 "read_sas", 

325 "read_spss", 

326 "read_sql", 

327 "read_sql_query", 

328 "read_sql_table", 

329 "read_stata", 

330 "read_table", 

331 "read_xml", 

332 "reset_option", 

333 "set_eng_float_format", 

334 "set_option", 

335 "show_versions", 

336 "test", 

337 "testing", 

338 "timedelta_range", 

339 "to_datetime", 

340 "to_numeric", 

341 "to_pickle", 

342 "to_timedelta", 

343 "tseries", 

344 "unique", 

345 "wide_to_long", 

346]