-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLN: use idiomatic pandas_dtypes in pandas/dtypes/common.py (#24541)
- Loading branch information
Showing
13 changed files
with
349 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from pandas.api.types import pandas_dtype | ||
|
||
import numpy as np | ||
from .pandas_vb_common import ( | ||
numeric_dtypes, datetime_dtypes, string_dtypes, extension_dtypes) | ||
|
||
|
||
_numpy_dtypes = [np.dtype(dtype) | ||
for dtype in (numeric_dtypes + | ||
datetime_dtypes + | ||
string_dtypes)] | ||
_dtypes = _numpy_dtypes + extension_dtypes | ||
|
||
|
||
class Dtypes(object): | ||
params = (_dtypes + | ||
list(map(lambda dt: dt.name, _dtypes))) | ||
param_names = ['dtype'] | ||
|
||
def time_pandas_dtype(self, dtype): | ||
pandas_dtype(dtype) | ||
|
||
|
||
class DtypesInvalid(object): | ||
param_names = ['dtype'] | ||
params = ['scalar-string', 'scalar-int', 'list-string', 'array-string'] | ||
data_dict = {'scalar-string': 'foo', | ||
'scalar-int': 1, | ||
'list-string': ['foo'] * 1000, | ||
'array-string': np.array(['foo'] * 1000)} | ||
|
||
def time_pandas_dtype_invalid(self, dtype): | ||
try: | ||
pandas_dtype(self.data_dict[dtype]) | ||
except TypeError: | ||
pass | ||
|
||
|
||
from .pandas_vb_common import setup # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.