|
2 | 2 | import sys
|
3 | 3 |
|
4 | 4 | import pandas as pd
|
| 5 | +from pandas.api.types import is_list_like, is_number |
5 | 6 | import pandas.io.common as com
|
| 7 | +from pandas.util.testing import assert_frame_equal |
6 | 8 |
|
7 | 9 | PY3 = sys.version_info >= (3, 0)
|
8 | 10 |
|
9 | 11 | PANDAS_VERSION = LooseVersion(pd.__version__)
|
10 | 12 |
|
11 |
| -PANDAS_0190 = PANDAS_VERSION >= LooseVersion("0.19.0") |
12 |
| -PANDAS_0200 = PANDAS_VERSION >= LooseVersion("0.20.0") |
13 | 13 | PANDAS_0210 = PANDAS_VERSION >= LooseVersion("0.21.0")
|
| 14 | +PANDAS_0220 = PANDAS_VERSION >= LooseVersion("0.22.0") |
14 | 15 | PANDAS_0230 = PANDAS_VERSION >= LooseVersion("0.23.0")
|
15 | 16 |
|
16 |
| -if PANDAS_0190: |
17 |
| - from pandas.api.types import is_number |
18 |
| - from pandas.util.testing import assert_frame_equal |
19 |
| -else: |
20 |
| - from pandas.core.common import is_number |
21 |
| - from pandas.testing import assert_frame_equal |
22 |
| - |
23 |
| -if PANDAS_0200: |
24 |
| - from pandas.util.testing import assert_raises_regex |
25 | 17 |
|
26 |
| - def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None): |
| 18 | +def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None): |
27 | 19 |
|
28 |
| - # Dictionaries are no longer considered valid inputs |
29 |
| - # for "get_filepath_or_buffer" starting in pandas >= 0.20.0 |
30 |
| - if isinstance(filepath_or_buffer, dict): |
31 |
| - return filepath_or_buffer, encoding, compression |
| 20 | + # Dictionaries are no longer considered valid inputs |
| 21 | + # for "get_filepath_or_buffer" starting in pandas >= 0.20.0 |
| 22 | + if isinstance(filepath_or_buffer, dict): |
| 23 | + return filepath_or_buffer, encoding, compression |
32 | 24 |
|
33 |
| - return com.get_filepath_or_buffer( |
34 |
| - filepath_or_buffer, encoding=encoding, compression=None |
35 |
| - ) |
| 25 | + return com.get_filepath_or_buffer( |
| 26 | + filepath_or_buffer, encoding=encoding, compression=None |
| 27 | + ) |
36 | 28 |
|
37 | 29 |
|
38 |
| -else: |
39 |
| - from pandas.util.testing import assertRaisesRegexp as assert_raises_regex |
40 |
| - |
41 |
| - get_filepath_or_buffer = com.get_filepath_or_buffer |
42 |
| - |
43 |
| -if PANDAS_0190: |
44 |
| - from pandas.api.types import is_list_like |
45 |
| -else: |
46 |
| - from pandas.core.common import is_list_like |
47 |
| - |
48 | 30 | if PY3:
|
49 | 31 | from urllib.error import HTTPError
|
50 | 32 | from functools import reduce
|
|
0 commit comments