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

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

41 statements  

1from __future__ import annotations 

2 

3import os 

4import warnings 

5 

6__docformat__ = "restructuredtext" 

7 

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

9_hard_dependencies = ("numpy", "pytz", "dateutil") 

10_missing_dependencies = [] 

11 

12for _dependency in _hard_dependencies: 

13 try: 

14 __import__(_dependency) 

15 except ImportError as _e: # pragma: no cover 

16 _missing_dependencies.append(f"{_dependency}: {_e}") 

17 

18if _missing_dependencies: # pragma: no cover 

19 raise ImportError( 

20 "Unable to import required dependencies:\n" + "\n".join(_missing_dependencies) 

21 ) 

22del _hard_dependencies, _dependency, _missing_dependencies 

23 

24try: 

25 # numpy compat 

26 from pandas.compat import ( 

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

28 ) 

29except ImportError as _err: # pragma: no cover 

30 _module = _err.name 

31 raise ImportError( 

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

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

34 "'python setup.py build_ext' to build the C extensions first." 

35 ) from _err 

36 

37from pandas._config import ( 

38 get_option, 

39 set_option, 

40 reset_option, 

41 describe_option, 

42 option_context, 

43 options, 

44) 

45 

46# let init-time option registration happen 

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

48 

49from pandas.core.api import ( 

50 # dtype 

51 ArrowDtype, 

52 Int8Dtype, 

53 Int16Dtype, 

54 Int32Dtype, 

55 Int64Dtype, 

56 UInt8Dtype, 

57 UInt16Dtype, 

58 UInt32Dtype, 

59 UInt64Dtype, 

60 Float32Dtype, 

61 Float64Dtype, 

62 CategoricalDtype, 

63 PeriodDtype, 

64 IntervalDtype, 

65 DatetimeTZDtype, 

66 StringDtype, 

67 BooleanDtype, 

68 # missing 

69 NA, 

70 isna, 

71 isnull, 

72 notna, 

73 notnull, 

74 # indexes 

75 Index, 

76 CategoricalIndex, 

77 RangeIndex, 

78 MultiIndex, 

79 IntervalIndex, 

80 TimedeltaIndex, 

81 DatetimeIndex, 

82 PeriodIndex, 

83 IndexSlice, 

84 # tseries 

85 NaT, 

86 Period, 

87 period_range, 

88 Timedelta, 

89 timedelta_range, 

90 Timestamp, 

91 date_range, 

92 bdate_range, 

93 Interval, 

94 interval_range, 

95 DateOffset, 

96 # conversion 

97 to_numeric, 

98 to_datetime, 

99 to_timedelta, 

100 # misc 

101 Flags, 

102 Grouper, 

103 factorize, 

104 unique, 

105 value_counts, 

106 NamedAgg, 

107 array, 

108 Categorical, 

109 set_eng_float_format, 

110 Series, 

111 DataFrame, 

112) 

113 

114from pandas.core.dtypes.dtypes import SparseDtype 

115 

116from pandas.tseries.api import infer_freq 

117from pandas.tseries import offsets 

118 

119from pandas.core.computation.api import eval 

120 

121from pandas.core.reshape.api import ( 

122 concat, 

123 lreshape, 

124 melt, 

125 wide_to_long, 

126 merge, 

127 merge_asof, 

128 merge_ordered, 

129 crosstab, 

130 pivot, 

131 pivot_table, 

132 get_dummies, 

133 from_dummies, 

134 cut, 

135 qcut, 

136) 

137 

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

139from pandas import testing 

140from pandas.util._print_versions import show_versions 

141 

142from pandas.io.api import ( 

143 # excel 

144 ExcelFile, 

145 ExcelWriter, 

146 read_excel, 

147 # parsers 

148 read_csv, 

149 read_fwf, 

150 read_table, 

151 # pickle 

152 read_pickle, 

153 to_pickle, 

154 # pytables 

155 HDFStore, 

156 read_hdf, 

157 # sql 

158 read_sql, 

159 read_sql_query, 

160 read_sql_table, 

161 # misc 

162 read_clipboard, 

163 read_parquet, 

164 read_orc, 

165 read_feather, 

166 read_gbq, 

167 read_html, 

168 read_xml, 

169 read_json, 

170 read_stata, 

171 read_sas, 

172 read_spss, 

173) 

174 

175from pandas.io.json._normalize import json_normalize 

176 

177from pandas.util._tester import test 

178 

179# use the closest tagged version if possible 

180_built_with_meson = False 

181try: 

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

183 __version__, 

184 __git_version__, 

185 ) 

186 

187 _built_with_meson = True 

188except ImportError: 

189 from pandas._version import get_versions 

190 

191 v = get_versions() 

192 __version__ = v.get("closest-tag", v["version"]) 

193 __git_version__ = v.get("full-revisionid") 

194 del get_versions, v 

195 

196# GH#55043 - deprecation of the data_manager option 

197if "PANDAS_DATA_MANAGER" in os.environ: 

198 warnings.warn( 

199 "The env variable PANDAS_DATA_MANAGER is set. The data_manager option is " 

200 "deprecated and will be removed in a future version. Only the BlockManager " 

201 "will be available. Unset this environment variable to silence this warning.", 

202 FutureWarning, 

203 stacklevel=2, 

204 ) 

205 

206del warnings, os 

207 

208# module level doc-string 

209__doc__ = """ 

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

211===================================================================== 

212 

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

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

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

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

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

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

219its way toward this goal. 

220 

221Main Features 

222------------- 

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

224 

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

226 point data. 

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

228 higher dimensional objects 

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

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

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

232 computations. 

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

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

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

236 and NumPy data structures into DataFrame objects. 

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

238 data sets. 

239 - Intuitive merging and joining data sets. 

240 - Flexible reshaping and pivoting of data sets. 

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

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

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

244 format. 

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

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

247""" 

248 

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

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

251# based on the documentation. 

252__all__ = [ 

253 "ArrowDtype", 

254 "BooleanDtype", 

255 "Categorical", 

256 "CategoricalDtype", 

257 "CategoricalIndex", 

258 "DataFrame", 

259 "DateOffset", 

260 "DatetimeIndex", 

261 "DatetimeTZDtype", 

262 "ExcelFile", 

263 "ExcelWriter", 

264 "Flags", 

265 "Float32Dtype", 

266 "Float64Dtype", 

267 "Grouper", 

268 "HDFStore", 

269 "Index", 

270 "IndexSlice", 

271 "Int16Dtype", 

272 "Int32Dtype", 

273 "Int64Dtype", 

274 "Int8Dtype", 

275 "Interval", 

276 "IntervalDtype", 

277 "IntervalIndex", 

278 "MultiIndex", 

279 "NA", 

280 "NaT", 

281 "NamedAgg", 

282 "Period", 

283 "PeriodDtype", 

284 "PeriodIndex", 

285 "RangeIndex", 

286 "Series", 

287 "SparseDtype", 

288 "StringDtype", 

289 "Timedelta", 

290 "TimedeltaIndex", 

291 "Timestamp", 

292 "UInt16Dtype", 

293 "UInt32Dtype", 

294 "UInt64Dtype", 

295 "UInt8Dtype", 

296 "api", 

297 "array", 

298 "arrays", 

299 "bdate_range", 

300 "concat", 

301 "crosstab", 

302 "cut", 

303 "date_range", 

304 "describe_option", 

305 "errors", 

306 "eval", 

307 "factorize", 

308 "get_dummies", 

309 "from_dummies", 

310 "get_option", 

311 "infer_freq", 

312 "interval_range", 

313 "io", 

314 "isna", 

315 "isnull", 

316 "json_normalize", 

317 "lreshape", 

318 "melt", 

319 "merge", 

320 "merge_asof", 

321 "merge_ordered", 

322 "notna", 

323 "notnull", 

324 "offsets", 

325 "option_context", 

326 "options", 

327 "period_range", 

328 "pivot", 

329 "pivot_table", 

330 "plotting", 

331 "qcut", 

332 "read_clipboard", 

333 "read_csv", 

334 "read_excel", 

335 "read_feather", 

336 "read_fwf", 

337 "read_gbq", 

338 "read_hdf", 

339 "read_html", 

340 "read_json", 

341 "read_orc", 

342 "read_parquet", 

343 "read_pickle", 

344 "read_sas", 

345 "read_spss", 

346 "read_sql", 

347 "read_sql_query", 

348 "read_sql_table", 

349 "read_stata", 

350 "read_table", 

351 "read_xml", 

352 "reset_option", 

353 "set_eng_float_format", 

354 "set_option", 

355 "show_versions", 

356 "test", 

357 "testing", 

358 "timedelta_range", 

359 "to_datetime", 

360 "to_numeric", 

361 "to_pickle", 

362 "to_timedelta", 

363 "tseries", 

364 "unique", 

365 "value_counts", 

366 "wide_to_long", 

367]