1
1
from __future__ import annotations
2
2
3
- import inspect
4
-
5
3
__docformat__ = "restructuredtext"
6
4
7
5
# Let users know if they're missing any of our hard dependencies
24
22
from pandas .compat import is_numpy_dev as _is_numpy_dev # pyright: ignore # noqa:F401
25
23
26
24
try :
27
- from pandas ._libs import (
28
- hashtable as _hashtable ,
29
- lib as _lib ,
30
- tslib as _tslib ,
31
- )
25
+ from pandas ._libs import hashtable as _hashtable , lib as _lib , tslib as _tslib
32
26
except ImportError as _err : # pragma: no cover
33
27
_module = _err .name
34
28
raise ImportError (
40
34
del _tslib , _lib , _hashtable
41
35
42
36
from pandas ._config import (
43
- describe_option ,
44
37
get_option ,
38
+ set_option ,
39
+ reset_option ,
40
+ describe_option ,
45
41
option_context ,
46
42
options ,
47
- reset_option ,
48
- set_option ,
49
43
)
50
44
51
- from pandas .util ._print_versions import show_versions
52
- from pandas .util ._tester import test
53
-
54
- from pandas import (
55
- api ,
56
- arrays ,
57
- errors ,
58
- io ,
59
- plotting ,
60
- tseries ,
61
- )
62
- from pandas import testing # noqa:PDF015
45
+ # let init-time option registration happen
46
+ import pandas .core .config_init # pyright: ignore # noqa:F401
63
47
64
- # use the closest tagged version if possible
65
- from pandas ._version import get_versions
66
- from pandas .core .api import ( # dtype; missing; indexes; tseries; conversion; misc
67
- NA ,
68
- BooleanDtype ,
69
- Categorical ,
70
- CategoricalDtype ,
71
- CategoricalIndex ,
72
- DataFrame ,
73
- DateOffset ,
74
- DatetimeIndex ,
75
- DatetimeTZDtype ,
76
- Flags ,
77
- Float32Dtype ,
78
- Float64Dtype ,
79
- Grouper ,
80
- Index ,
81
- IndexSlice ,
48
+ from pandas .core .api import (
49
+ # dtype
82
50
Int8Dtype ,
83
51
Int16Dtype ,
84
52
Int32Dtype ,
85
53
Int64Dtype ,
86
- Interval ,
87
- IntervalDtype ,
88
- IntervalIndex ,
89
- MultiIndex ,
90
- NamedAgg ,
91
- NaT ,
92
- Period ,
93
- PeriodDtype ,
94
- PeriodIndex ,
95
- RangeIndex ,
96
- Series ,
97
- StringDtype ,
98
- Timedelta ,
99
- TimedeltaIndex ,
100
- Timestamp ,
101
54
UInt8Dtype ,
102
55
UInt16Dtype ,
103
56
UInt32Dtype ,
104
57
UInt64Dtype ,
105
- array ,
106
- bdate_range ,
107
- date_range ,
108
- factorize ,
109
- interval_range ,
58
+ Float32Dtype ,
59
+ Float64Dtype ,
60
+ CategoricalDtype ,
61
+ PeriodDtype ,
62
+ IntervalDtype ,
63
+ DatetimeTZDtype ,
64
+ StringDtype ,
65
+ BooleanDtype ,
66
+ # missing
67
+ NA ,
110
68
isna ,
111
69
isnull ,
112
70
notna ,
113
71
notnull ,
72
+ # indexes
73
+ Index ,
74
+ CategoricalIndex ,
75
+ RangeIndex ,
76
+ MultiIndex ,
77
+ IntervalIndex ,
78
+ TimedeltaIndex ,
79
+ DatetimeIndex ,
80
+ PeriodIndex ,
81
+ IndexSlice ,
82
+ # tseries
83
+ NaT ,
84
+ Period ,
114
85
period_range ,
115
- set_eng_float_format ,
86
+ Timedelta ,
116
87
timedelta_range ,
117
- to_datetime ,
88
+ Timestamp ,
89
+ date_range ,
90
+ bdate_range ,
91
+ Interval ,
92
+ interval_range ,
93
+ DateOffset ,
94
+ # conversion
118
95
to_numeric ,
96
+ to_datetime ,
119
97
to_timedelta ,
98
+ # misc
99
+ Flags ,
100
+ Grouper ,
101
+ factorize ,
120
102
unique ,
121
103
value_counts ,
104
+ NamedAgg ,
105
+ array ,
106
+ Categorical ,
107
+ set_eng_float_format ,
108
+ Series ,
109
+ DataFrame ,
122
110
)
111
+
123
112
from pandas .core .arrays .sparse import SparseDtype
113
+
114
+ from pandas .tseries .api import infer_freq
115
+ from pandas .tseries import offsets
116
+
124
117
from pandas .core .computation .api import eval
125
118
126
- # let init-time option registration happen
127
- import pandas .core .config_init # pyright: ignore # noqa:F401
128
119
from pandas .core .reshape .api import (
129
120
concat ,
130
- crosstab ,
131
- cut ,
132
- from_dummies ,
133
- get_dummies ,
134
121
lreshape ,
135
122
melt ,
123
+ wide_to_long ,
136
124
merge ,
137
125
merge_asof ,
138
126
merge_ordered ,
127
+ crosstab ,
139
128
pivot ,
140
129
pivot_table ,
130
+ get_dummies ,
131
+ from_dummies ,
132
+ cut ,
141
133
qcut ,
142
- wide_to_long ,
143
134
)
144
135
145
- from pandas .io .api import ( # excel; parsers; pickle; pytables; sql; misc
136
+ from pandas import api , arrays , errors , io , plotting , tseries
137
+ from pandas import testing # noqa:PDF015
138
+ from pandas .util ._print_versions import show_versions
139
+
140
+ from pandas .io .api import (
141
+ # excel
146
142
ExcelFile ,
147
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
148
153
HDFStore ,
154
+ read_hdf ,
155
+ # sql
156
+ read_sql ,
157
+ read_sql_query ,
158
+ read_sql_table ,
159
+ # misc
149
160
read_clipboard ,
150
- read_csv ,
151
- read_excel ,
161
+ read_parquet ,
162
+ read_orc ,
152
163
read_feather ,
153
- read_fwf ,
154
164
read_gbq ,
155
- read_hdf ,
156
165
read_html ,
166
+ read_xml ,
157
167
read_json ,
158
- read_orc ,
159
- read_parquet ,
160
- read_pickle ,
168
+ read_stata ,
161
169
read_sas ,
162
170
read_spss ,
163
- read_sql ,
164
- read_sql_query ,
165
- read_sql_table ,
166
- read_stata ,
167
- read_table ,
168
- read_xml ,
169
- to_pickle ,
170
171
)
172
+
171
173
from pandas .io .json import _json_normalize as json_normalize
172
- from pandas .tseries import offsets
173
- from pandas .tseries .api import infer_freq
174
+
175
+ from pandas .util ._tester import test
176
+
177
+ # use the closest tagged version if possible
178
+ from pandas ._version import get_versions
174
179
175
180
v = get_versions ()
176
181
__version__ = v .get ("closest-tag" , v ["version" ])
@@ -190,21 +195,16 @@ def __dir__() -> list[str]:
190
195
191
196
def __getattr__ (name ):
192
197
import warnings
193
- from pandas .util ._exceptions import find_stack_level
194
198
195
199
if name in __deprecated_num_index_names :
196
200
warnings .warn (
197
201
f"pandas.{ name } is deprecated "
198
202
"and will be removed from pandas in a future version. "
199
203
"Use pandas.Index with the appropriate dtype instead." ,
200
204
FutureWarning ,
201
- stacklevel = find_stack_level (inspect .currentframe ()),
202
- )
203
- from pandas .core .api import (
204
- Float64Index ,
205
- Int64Index ,
206
- UInt64Index ,
205
+ stacklevel = 2 ,
207
206
)
207
+ from pandas .core .api import Float64Index , Int64Index , UInt64Index
208
208
209
209
return {
210
210
"Float64Index" : Float64Index ,
@@ -217,7 +217,7 @@ def __getattr__(name):
217
217
"and will be removed from pandas in a future version. "
218
218
"Import from datetime module instead." ,
219
219
FutureWarning ,
220
- stacklevel = find_stack_level ( inspect . currentframe ()) ,
220
+ stacklevel = 2 ,
221
221
)
222
222
223
223
from datetime import datetime as dt
@@ -231,7 +231,7 @@ def __getattr__(name):
231
231
"and will be removed from pandas in a future version. "
232
232
"Import numpy directly instead." ,
233
233
FutureWarning ,
234
- stacklevel = find_stack_level ( inspect . currentframe ()) ,
234
+ stacklevel = 2 ,
235
235
)
236
236
import numpy as np
237
237
@@ -242,7 +242,7 @@ def __getattr__(name):
242
242
f"The { name } class is removed from pandas. Accessing it from "
243
243
"the top-level namespace will also be removed in the next version." ,
244
244
FutureWarning ,
245
- stacklevel = find_stack_level ( inspect . currentframe ()) ,
245
+ stacklevel = 2 ,
246
246
)
247
247
248
248
return type (name , (), {})
@@ -254,7 +254,7 @@ def __getattr__(name):
254
254
"and will be removed from pandas in a future version. "
255
255
"Use pandas.arrays.SparseArray instead." ,
256
256
FutureWarning ,
257
- stacklevel = find_stack_level ( inspect . currentframe ()) ,
257
+ stacklevel = 2 ,
258
258
)
259
259
from pandas .core .arrays .sparse import SparseArray as _SparseArray
260
260
0 commit comments