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

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

36 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 array, 

104 Categorical, 

105 set_eng_float_format, 

106 Series, 

107 DataFrame, 

108) 

109from pandas.core.col import col 

110 

111from pandas.core.dtypes.dtypes import SparseDtype 

112 

113from pandas.tseries.api import infer_freq 

114from pandas.tseries import offsets 

115 

116from pandas.core.computation.api import eval 

117 

118from pandas.core.reshape.api import ( 

119 concat, 

120 lreshape, 

121 melt, 

122 wide_to_long, 

123 merge, 

124 merge_asof, 

125 merge_ordered, 

126 crosstab, 

127 pivot, 

128 pivot_table, 

129 get_dummies, 

130 from_dummies, 

131 cut, 

132 qcut, 

133) 

134 

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

136from pandas import testing 

137from pandas.util._print_versions import show_versions 

138 

139from pandas.io.api import ( 

140 # excel 

141 ExcelFile, 

142 ExcelWriter, 

143 read_excel, 

144 # parsers 

145 read_csv, 

146 read_fwf, 

147 read_table, 

148 # pickle 

149 read_pickle, 

150 to_pickle, 

151 # pytables 

152 HDFStore, 

153 read_hdf, 

154 # sql 

155 read_sql, 

156 read_sql_query, 

157 read_sql_table, 

158 # misc 

159 read_clipboard, 

160 read_parquet, 

161 read_orc, 

162 read_feather, 

163 read_html, 

164 read_xml, 

165 read_json, 

166 read_stata, 

167 read_sas, 

168 read_spss, 

169 read_iceberg, 

170) 

171 

172from pandas.io.json._normalize import json_normalize 

173 

174from pandas.util._tester import test 

175 

176# use the closest tagged version if possible 

177_built_with_meson = False 

178try: 

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

180 __version__, 

181 __git_version__, 

182 ) 

183 

184 _built_with_meson = True 

185except ImportError: 

186 from pandas._version import get_versions 

187 

188 v = get_versions() 

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

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

191 del get_versions, v 

192 

193 

194# module level doc-string 

195__doc__ = """ 

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

197===================================================================== 

198 

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

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

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

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

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

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

205its way toward this goal. 

206 

207Main Features 

208------------- 

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

210 

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

212 point data. 

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

214 higher dimensional objects 

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

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

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

218 computations. 

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

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

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

222 and NumPy data structures into DataFrame objects. 

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

224 data sets. 

225 - Intuitive merging and joining data sets. 

226 - Flexible reshaping and pivoting of data sets. 

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

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

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

230 format. 

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

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

233""" 

234 

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

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

237# based on the documentation. 

238__all__ = [ 

239 "NA", 

240 "ArrowDtype", 

241 "BooleanDtype", 

242 "Categorical", 

243 "CategoricalDtype", 

244 "CategoricalIndex", 

245 "DataFrame", 

246 "DateOffset", 

247 "DatetimeIndex", 

248 "DatetimeTZDtype", 

249 "ExcelFile", 

250 "ExcelWriter", 

251 "Flags", 

252 "Float32Dtype", 

253 "Float64Dtype", 

254 "Grouper", 

255 "HDFStore", 

256 "Index", 

257 "IndexSlice", 

258 "Int8Dtype", 

259 "Int16Dtype", 

260 "Int32Dtype", 

261 "Int64Dtype", 

262 "Interval", 

263 "IntervalDtype", 

264 "IntervalIndex", 

265 "MultiIndex", 

266 "NaT", 

267 "NamedAgg", 

268 "Period", 

269 "PeriodDtype", 

270 "PeriodIndex", 

271 "RangeIndex", 

272 "Series", 

273 "SparseDtype", 

274 "StringDtype", 

275 "Timedelta", 

276 "TimedeltaIndex", 

277 "Timestamp", 

278 "UInt8Dtype", 

279 "UInt16Dtype", 

280 "UInt32Dtype", 

281 "UInt64Dtype", 

282 "api", 

283 "array", 

284 "arrays", 

285 "bdate_range", 

286 "col", 

287 "concat", 

288 "crosstab", 

289 "cut", 

290 "date_range", 

291 "describe_option", 

292 "errors", 

293 "eval", 

294 "factorize", 

295 "from_dummies", 

296 "get_dummies", 

297 "get_option", 

298 "infer_freq", 

299 "interval_range", 

300 "io", 

301 "isna", 

302 "isnull", 

303 "json_normalize", 

304 "lreshape", 

305 "melt", 

306 "merge", 

307 "merge_asof", 

308 "merge_ordered", 

309 "notna", 

310 "notnull", 

311 "offsets", 

312 "option_context", 

313 "options", 

314 "period_range", 

315 "pivot", 

316 "pivot_table", 

317 "plotting", 

318 "qcut", 

319 "read_clipboard", 

320 "read_csv", 

321 "read_excel", 

322 "read_feather", 

323 "read_fwf", 

324 "read_hdf", 

325 "read_html", 

326 "read_iceberg", 

327 "read_json", 

328 "read_orc", 

329 "read_parquet", 

330 "read_pickle", 

331 "read_sas", 

332 "read_spss", 

333 "read_sql", 

334 "read_sql_query", 

335 "read_sql_table", 

336 "read_stata", 

337 "read_table", 

338 "read_xml", 

339 "reset_option", 

340 "set_eng_float_format", 

341 "set_option", 

342 "show_versions", 

343 "test", 

344 "testing", 

345 "timedelta_range", 

346 "to_datetime", 

347 "to_numeric", 

348 "to_pickle", 

349 "to_timedelta", 

350 "tseries", 

351 "unique", 

352 "wide_to_long", 

353]