|
1 | 1 | # flake8: noqa
|
2 | 2 |
|
3 |
| -__docformat__ = 'restructuredtext' |
| 3 | +__docformat__ = "restructuredtext" |
4 | 4 |
|
5 | 5 | # Let users know if they're missing any of our hard dependencies
|
6 | 6 | hard_dependencies = ("numpy", "pytz", "dateutil")
|
|
13 | 13 | missing_dependencies.append("{0}: {1}".format(dependency, str(e)))
|
14 | 14 |
|
15 | 15 | if missing_dependencies:
|
16 |
| - raise ImportError("Unable to import required dependencies:\n" + "\n".join(missing_dependencies)) |
| 16 | + raise ImportError( |
| 17 | + "Unable to import required dependencies:\n" + "\n".join(missing_dependencies) |
| 18 | + ) |
17 | 19 | del hard_dependencies, dependency, missing_dependencies
|
18 | 20 |
|
19 | 21 | # numpy compat
|
20 | 22 | from pandas.compat.numpy import (
|
21 |
| - _np_version_under1p14, _np_version_under1p15, _np_version_under1p16, |
22 |
| - _np_version_under1p17) |
| 23 | + _np_version_under1p14, |
| 24 | + _np_version_under1p15, |
| 25 | + _np_version_under1p16, |
| 26 | + _np_version_under1p17, |
| 27 | +) |
23 | 28 |
|
24 | 29 | try:
|
25 |
| - from pandas._libs import (hashtable as _hashtable, |
26 |
| - lib as _lib, |
27 |
| - tslib as _tslib) |
| 30 | + from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib |
28 | 31 | except ImportError as e: # pragma: no cover
|
29 | 32 | # hack but overkill to use re
|
30 |
| - module = str(e).replace('cannot import name ', '') |
31 |
| - raise ImportError("C extension: {0} not built. If you want to import " |
32 |
| - "pandas from the source directory, you may need to run " |
33 |
| - "'python setup.py build_ext --inplace --force' to build " |
34 |
| - "the C extensions first.".format(module)) |
| 33 | + module = str(e).replace("cannot import name ", "") |
| 34 | + raise ImportError( |
| 35 | + "C extension: {0} not built. If you want to import " |
| 36 | + "pandas from the source directory, you may need to run " |
| 37 | + "'python setup.py build_ext --inplace --force' to build " |
| 38 | + "the C extensions first.".format(module) |
| 39 | + ) |
35 | 40 |
|
36 | 41 | from datetime import datetime
|
37 | 42 |
|
38 |
| -from pandas._config import (get_option, set_option, reset_option, |
39 |
| - describe_option, option_context, options) |
| 43 | +from pandas._config import ( |
| 44 | + get_option, |
| 45 | + set_option, |
| 46 | + reset_option, |
| 47 | + describe_option, |
| 48 | + option_context, |
| 49 | + options, |
| 50 | +) |
40 | 51 |
|
41 | 52 | # let init-time option registration happen
|
42 | 53 | import pandas.core.config_init
|
43 | 54 |
|
44 | 55 | from pandas.core.api import (
|
45 | 56 | # dtype
|
46 |
| - Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype, UInt8Dtype, |
47 |
| - UInt16Dtype, UInt32Dtype, UInt64Dtype, CategoricalDtype, |
48 |
| - PeriodDtype, IntervalDtype, DatetimeTZDtype, |
49 |
| - |
| 57 | + Int8Dtype, |
| 58 | + Int16Dtype, |
| 59 | + Int32Dtype, |
| 60 | + Int64Dtype, |
| 61 | + UInt8Dtype, |
| 62 | + UInt16Dtype, |
| 63 | + UInt32Dtype, |
| 64 | + UInt64Dtype, |
| 65 | + CategoricalDtype, |
| 66 | + PeriodDtype, |
| 67 | + IntervalDtype, |
| 68 | + DatetimeTZDtype, |
50 | 69 | # missing
|
51 |
| - isna, isnull, notna, notnull, |
52 |
| - |
| 70 | + isna, |
| 71 | + isnull, |
| 72 | + notna, |
| 73 | + notnull, |
53 | 74 | # indexes
|
54 |
| - Index, CategoricalIndex, Int64Index, UInt64Index, RangeIndex, |
55 |
| - Float64Index, MultiIndex, IntervalIndex, TimedeltaIndex, |
56 |
| - DatetimeIndex, PeriodIndex, IndexSlice, |
57 |
| - |
| 75 | + Index, |
| 76 | + CategoricalIndex, |
| 77 | + Int64Index, |
| 78 | + UInt64Index, |
| 79 | + RangeIndex, |
| 80 | + Float64Index, |
| 81 | + MultiIndex, |
| 82 | + IntervalIndex, |
| 83 | + TimedeltaIndex, |
| 84 | + DatetimeIndex, |
| 85 | + PeriodIndex, |
| 86 | + IndexSlice, |
58 | 87 | # tseries
|
59 |
| - NaT, Period, period_range, Timedelta, timedelta_range, |
60 |
| - Timestamp, date_range, bdate_range, Interval, interval_range, |
| 88 | + NaT, |
| 89 | + Period, |
| 90 | + period_range, |
| 91 | + Timedelta, |
| 92 | + timedelta_range, |
| 93 | + Timestamp, |
| 94 | + date_range, |
| 95 | + bdate_range, |
| 96 | + Interval, |
| 97 | + interval_range, |
61 | 98 | DateOffset,
|
62 |
| - |
63 | 99 | # conversion
|
64 |
| - to_numeric, to_datetime, to_timedelta, |
65 |
| - |
| 100 | + to_numeric, |
| 101 | + to_datetime, |
| 102 | + to_timedelta, |
66 | 103 | # misc
|
67 |
| - np, Grouper, factorize, unique, value_counts, NamedAgg, |
68 |
| - array, Categorical, set_eng_float_format, Series, DataFrame) |
| 104 | + np, |
| 105 | + Grouper, |
| 106 | + factorize, |
| 107 | + unique, |
| 108 | + value_counts, |
| 109 | + NamedAgg, |
| 110 | + array, |
| 111 | + Categorical, |
| 112 | + set_eng_float_format, |
| 113 | + Series, |
| 114 | + DataFrame, |
| 115 | +) |
69 | 116 |
|
70 | 117 | from pandas.core.sparse.api import (
|
71 |
| - SparseArray, SparseDataFrame, SparseSeries, SparseDtype) |
| 118 | + SparseArray, |
| 119 | + SparseDataFrame, |
| 120 | + SparseSeries, |
| 121 | + SparseDtype, |
| 122 | +) |
72 | 123 |
|
73 | 124 | from pandas.tseries.api import infer_freq
|
74 | 125 | from pandas.tseries import offsets
|
75 | 126 |
|
76 | 127 | from pandas.core.computation.api import eval
|
77 | 128 |
|
78 | 129 | from pandas.core.reshape.api import (
|
79 |
| - concat, lreshape, melt, wide_to_long, merge, merge_asof, |
80 |
| - merge_ordered, crosstab, pivot, pivot_table, get_dummies, |
81 |
| - cut, qcut) |
| 130 | + concat, |
| 131 | + lreshape, |
| 132 | + melt, |
| 133 | + wide_to_long, |
| 134 | + merge, |
| 135 | + merge_asof, |
| 136 | + merge_ordered, |
| 137 | + crosstab, |
| 138 | + pivot, |
| 139 | + pivot_table, |
| 140 | + get_dummies, |
| 141 | + cut, |
| 142 | + qcut, |
| 143 | +) |
82 | 144 |
|
83 | 145 | from pandas.util._print_versions import show_versions
|
84 | 146 |
|
85 | 147 | from pandas.io.api import (
|
86 | 148 | # excel
|
87 |
| - ExcelFile, ExcelWriter, read_excel, |
88 |
| - |
| 149 | + ExcelFile, |
| 150 | + ExcelWriter, |
| 151 | + read_excel, |
89 | 152 | # packers
|
90 |
| - read_msgpack, to_msgpack, |
91 |
| - |
| 153 | + read_msgpack, |
| 154 | + to_msgpack, |
92 | 155 | # parsers
|
93 |
| - read_csv, read_fwf, read_table, |
94 |
| - |
| 156 | + read_csv, |
| 157 | + read_fwf, |
| 158 | + read_table, |
95 | 159 | # pickle
|
96 |
| - read_pickle, to_pickle, |
97 |
| - |
| 160 | + read_pickle, |
| 161 | + to_pickle, |
98 | 162 | # pytables
|
99 |
| - HDFStore, read_hdf, |
100 |
| - |
| 163 | + HDFStore, |
| 164 | + read_hdf, |
101 | 165 | # sql
|
102 |
| - read_sql, read_sql_query, |
| 166 | + read_sql, |
| 167 | + read_sql_query, |
103 | 168 | read_sql_table,
|
104 |
| - |
105 | 169 | # misc
|
106 |
| - read_clipboard, read_parquet, read_feather, read_gbq, |
107 |
| - read_html, read_json, read_stata, read_sas, read_spss) |
| 170 | + read_clipboard, |
| 171 | + read_parquet, |
| 172 | + read_feather, |
| 173 | + read_gbq, |
| 174 | + read_html, |
| 175 | + read_json, |
| 176 | + read_stata, |
| 177 | + read_sas, |
| 178 | + read_spss, |
| 179 | +) |
108 | 180 |
|
109 | 181 | from pandas.util._tester import test
|
110 | 182 | import pandas.testing
|
111 | 183 | import pandas.arrays
|
112 | 184 |
|
113 | 185 | # use the closest tagged version if possible
|
114 | 186 | from ._version import get_versions
|
| 187 | + |
115 | 188 | v = get_versions()
|
116 |
| -__version__ = v.get('closest-tag', v['version']) |
117 |
| -__git_version__ = v.get('full-revisionid') |
| 189 | +__version__ = v.get("closest-tag", v["version"]) |
| 190 | +__git_version__ = v.get("full-revisionid") |
118 | 191 | del get_versions, v
|
119 | 192 |
|
120 | 193 |
|
121 | 194 | # GH 27101
|
122 | 195 | # TODO: remove Panel compat in 1.0
|
123 | 196 | if pandas.compat.PY37:
|
| 197 | + |
124 | 198 | def __getattr__(name):
|
125 |
| - if name == 'Panel': |
| 199 | + if name == "Panel": |
126 | 200 | import warnings
|
| 201 | + |
127 | 202 | warnings.warn(
|
128 | 203 | "The Panel class is removed from pandas. Accessing it "
|
129 | 204 | "from the top-level namespace will also be removed in "
|
130 | 205 | "the next version",
|
131 |
| - FutureWarning, stacklevel=2) |
| 206 | + FutureWarning, |
| 207 | + stacklevel=2, |
| 208 | + ) |
132 | 209 |
|
133 | 210 | class Panel:
|
134 | 211 | pass
|
135 | 212 |
|
136 | 213 | return Panel
|
137 |
| - raise AttributeError( |
138 |
| - "module 'pandas' has no attribute '{}'".format(name)) |
| 214 | + raise AttributeError("module 'pandas' has no attribute '{}'".format(name)) |
| 215 | + |
| 216 | + |
139 | 217 | else:
|
| 218 | + |
140 | 219 | class Panel:
|
141 | 220 | pass
|
142 | 221 |
|
|
0 commit comments